stator
A math, geometry, and utility library
Classes | Namespaces | Macros | Typedefs | Functions
config.hpp File Reference

Fundamental typedef's and macros for stator. More...

#include <Eigen/Dense>

Go to the source code of this file.

Classes

class  stator::detail::choice< I >
 A class which recursively inherits from itself to allow ambiguous function definition ordering. More...
 
struct  stator::detail::choice< LAST_OVERLOAD_LVL >
 The lowest-priority overload level (closing the recursion) More...
 
struct  stator::detail::dependent_false< T >
 
struct  stator::detail::dependent_true< T >
 
struct  stator::detail::select_overload
 A class used to start the ambiguous function definition ordering calculation. More...
 

Namespaces

 stator
 The stator library namespace.
 
 stator::detail
 Namespace containing the details of the implmentation for general stator components.
 

Macros

#define STATOR_AUTORETURN(EXPR)   decltype(EXPR) { return EXPR; }
 A convenience Macro for defining auto return type functions. More...
 
#define STATOR_AUTORETURN_BYVALUE(EXPR)   STATOR_AUTORETURN(store(EXPR))
 A convenience Macro for defining auto by-value return type functions. More...
 

Typedefs

typedef choice< LAST_OVERLOAD_LVL > stator::detail::last_choice
 
template<typename Scalar , size_t D1, size_t D2>
using stator::Matrix = Eigen::Matrix< Scalar, D1, D2, Eigen::DontAlign >
 A convenience typedef for a non-aligned Eigen Matrix. More...
 
template<typename Scalar , size_t D>
using stator::Vector = Matrix< Scalar, D, 1 >
 A convenience typedef for a non-aligned Eigen Vector. More...
 

Functions

template<class T >
auto stator::detail::store (const T &val) -> decltype(store_impl(val, select_overload
 
template<class T >
auto stator::detail::store_impl (T val, choice< 0 >) -> decltype(typename std::decay< decltype(std::declval< T >().eval())>::type(val))
 
template<class T >
auto stator::detail::store_impl (T val, choice< 1 >) -> decltype(typename std::decay< T >::type(val))
 

Macro Definition Documentation

◆ STATOR_AUTORETURN

#define STATOR_AUTORETURN (   EXPR)    decltype(EXPR) { return EXPR; }

A fully generic addition function is written like so

template<typename T1, typename T2>
auto add(const T1& a, const T2& b) -> decltype(a+b)
{ return a+b; }

This requires repetiting the actual expression twice, once in the decltype to determine the resulting type of the expression and once again in the return statement to actually calculate it. This macro permits a simpler definition:

template<typename T1, typename T2>
auto add(const T1& a, const T2& b) -> STATOR_AUTORETURN(a+b)

This reduces the amount of code that has to be written and ensures consistency between the two definitions. It is redundant in later C++ standards.

Definition at line 51 of file config.hpp.

◆ STATOR_AUTORETURN_BYVALUE

#define STATOR_AUTORETURN_BYVALUE (   EXPR)    STATOR_AUTORETURN(store(EXPR))

This macro is identical to STATOR_AUTORETURN, except it ensures the return values are by reference. It does this by using the STORETYPE macro to calculate the return type.

Definition at line 107 of file config.hpp.