21 #ifndef RFFGEN_STATIC_CHECKS_HH 
   22 #define RFFGEN_STATIC_CHECKS_HH 
   24 #include <type_traits> 
   27 #include "../LinearAlgebra/extractRowsAndCols.hh" 
   44     template < 
class Arg , 
class ScalarArg > 
using TryMultiplicationWithArithmeticFromLeft  = decltype( std::declval<ScalarArg>() * std::declval<Arg>() );
 
   45     template < 
class Arg , 
class ScalarArg > 
using TryMultiplicationWithArithmeticFromRight = decltype( std::declval<Arg>() * std::declval<ScalarArg>() );
 
   46     template < 
class Arg , 
class ScalarArg > 
using TryInPlaceMultiplicationWithArithmetic   = decltype( std::declval<Arg>() *= std::declval<ScalarArg>() );
 
   48     template < 
class Arg , 
class ScalarArg , 
bool , 
class = 
void > 
struct MultiplicationWithArithmeticFromLeft                   : std::false_type {};
 
   49     template < 
class Arg , 
class ScalarArg , 
bool , 
class = 
void > 
struct MultiplicationWithArithmeticFromRight                  : std::false_type {};
 
   50     template < 
class Arg , 
class ScalarArg , 
bool , 
class = 
void > 
struct InPlaceMultiplicationWithArithmetic                    : std::false_type {};
 
   52     template < 
class Arg , 
class ScalarArg >
 
   53     struct MultiplicationWithArithmeticFromLeft< Arg , ScalarArg , true , 
void_t< TryMultiplicationWithArithmeticFromLeft<Arg,ScalarArg> > >
 
   57     template < 
class Arg , 
class ScalarArg >
 
   58     struct MultiplicationWithArithmeticFromRight< Arg , ScalarArg , true , 
void_t< TryMultiplicationWithArithmeticFromRight<Arg,ScalarArg> > >
 
   62     template < 
class Arg , 
class ScalarArg >
 
   63     struct InPlaceMultiplicationWithArithmetic< Arg , ScalarArg , true , 
void_t< TryInPlaceMultiplicationWithArithmetic<Arg,ScalarArg> > >
 
   69     template < 
class Arg1 , 
class Arg2 > 
using TryMultiplication = decltype( std::declval<Arg1>() * std::declval<Arg2>() );
 
   70     template < 
class Arg1 , 
class Arg2 > 
using TryInPlaceMultiplication = decltype( std::declval<Arg1>() *= std::declval<Arg2>() );
 
   71     template < 
class Arg1 , 
class Arg2 > 
using TryCallToRightMultiply = decltype( std::declval<Arg1>().rightmultiplyany(std::declval<Arg2>()) );
 
   73     template < 
class Arg1 , 
class Arg2 , 
bool , 
class = 
void > 
struct Multiplication                                  : std::false_type {};
 
   74     template < 
class Arg1 , 
class Arg2 , 
bool , 
class = 
void > 
struct InPlaceMultiplication                           : std::false_type {};
 
   75     template < 
class Arg1 , 
class Arg2 , 
bool , 
class = 
void > 
struct CallToRightMultiply                             : std::false_type {};
 
   77     template < 
class Arg1 , 
class Arg2 >
 
   78     struct Multiplication< Arg1 , Arg2 , true , 
void_t< TryMultiplication<Arg1,Arg2> > >                              : std::true_type {};
 
   80     template < 
class Arg1 , 
class Arg2 >
 
   81     struct InPlaceMultiplication< Arg1 , Arg2 , true , 
void_t< TryInPlaceMultiplication<Arg1,Arg2> > >                : std::true_type {};
 
   83     template < 
class Arg1 , 
class Arg2 >
 
   84     struct CallToRightMultiply< Arg1 , Arg2 , true , 
void_t< TryCallToRightMultiply<Arg1,Arg2> > >                    : std::true_type {};
 
   88     template < 
class Arg > 
using TrySummation = decltype( std::declval<Arg>() + std::declval<Arg>() );
 
   89     template < 
class Arg > 
using TryInPlaceSummation = decltype( std::declval<Arg>() += std::declval<Arg>() );
 
   91     template < 
class Arg ,  
bool , 
class = 
void > 
struct Summation                                                    : std::false_type {};
 
   92     template < 
class Arg ,  
bool , 
class = 
void > 
struct InPlaceSummation                                             : std::false_type {};
 
   94     template < 
class Arg > 
struct Summation< Arg , true , 
void_t< TrySummation<Arg> > >                               : std::true_type {};
 
   95     template < 
class Arg > 
struct InPlaceSummation< Arg , true , 
void_t< TryInPlaceSummation<Arg> > >                 : std::true_type {};
 
   99     template <
class Matrix>
 
  100     using TryAccessViaSquareBracketsForMatrix = decltype(std::declval<Matrix>()[0][0]);
 
  102     template <
class Vector>
 
  103     using TryAccessViaSquareBracketsForVector = decltype(std::declval<Vector>()[0]);
 
  105     template <
class Matrix>
 
  106     using TryAccessViaRoundBracketsForMatrix = decltype(std::declval<Matrix>()(0,0));
 
  108     template <
class Vector>
 
  109     using TryAccessViaRoundBracketsForVector = decltype(std::declval<Vector>()(0));
 
  111     template < 
class Matrix, 
class = 
void > 
struct AccessViaSquareBracketsForMatrix                                                     : std::false_type {};
 
  112     template <
class Matrix> 
struct AccessViaSquareBracketsForMatrix< Matrix , 
void_t<TryAccessViaSquareBracketsForMatrix<Matrix> > >    : std::true_type {};
 
  114     template < 
class Matrix, 
class = 
void > 
struct AccessViaRoundBracketsForMatrix                                                      : std::false_type {};
 
  115     template <
class Matrix> 
struct AccessViaRoundBracketsForMatrix< Matrix , 
void_t<TryAccessViaRoundBracketsForMatrix<Matrix> > >      : std::true_type {};
 
  117     template < 
class Vector, 
class = 
void > 
struct AccessViaSquareBracketsForVector                                                     : std::false_type {};
 
  118     template <
class Vector> 
struct AccessViaSquareBracketsForVector< Vector , 
void_t<TryAccessViaSquareBracketsForVector<Vector> > >    : std::true_type {};
 
  120     template < 
class Vector, 
class = 
void > 
struct AccessViaRoundBracketsForVector                                                      : std::false_type {};
 
  121     template <
class Vector> 
struct AccessViaRoundBracketsForVector< Vector , 
void_t<TryAccessViaRoundBracketsForVector<Vector> > >      : std::true_type {};
 
  126     using TryCallOfUpdate = decltype(std::declval<F>().update(std::declval<int>()));
 
  129     using TryCallOfUpdateVariable = decltype(std::declval<F>().
template updateVariable<0>(std::declval<int>()));
 
  131     template < 
class F , 
class = 
void > 
struct CallOfUpdate                                                           : std::false_type {};
 
  132     template < 
class F , 
class = 
void > 
struct CallOfUpdateVariable                                                   : std::false_type {};
 
  134     template < 
class F > 
struct CallOfUpdate< F , 
void_t< TryCallOfUpdate<F> > >                                      : std::true_type {};
 
  135     template < 
class F > 
struct CallOfUpdateVariable< F , 
void_t< TryCallOfUpdateVariable<F> > >                      : std::true_type {};
 
  145     template < 
class Arg , 
class ScalarArg >
 
  146     constexpr 
bool multiplicationWithArithmeticFromLeft()
 
  148       return MultiplicationWithArithmeticFromLeft<Arg,ScalarArg,!std::is_base_of<Base,Arg>() && !std::is_arithmetic<Arg>()>::value;
 
  155     template < 
class Arg , 
class ScalarArg >
 
  156     constexpr 
bool multiplicationWithArithmeticFromRight()
 
  158       return MultiplicationWithArithmeticFromRight<Arg,ScalarArg,!std::is_base_of<Base,Arg>() && !std::is_arithmetic<Arg>()>::value;
 
  165     template < 
class Arg , 
class ScalarArg >
 
  166     constexpr 
bool inPlaceMultiplicationWithArithmetic()
 
  168       return InPlaceMultiplicationWithArithmetic<Arg,ScalarArg,!std::is_base_of<Base,Arg>() && !std::is_arithmetic<Arg>()>::value;
 
  175     template < 
class Arg1 , 
class Arg2 >
 
  176     constexpr 
bool multiplication()
 
  178       return Multiplication<Arg1,Arg2,!std::is_base_of<Base,Arg1>() && !std::is_base_of<Base,Arg2>() && !std::is_arithmetic<Arg1>() && !std::is_arithmetic<Arg2>()>::value;
 
  185     template < 
class Arg1 , 
class Arg2 >
 
  186     constexpr 
bool inPlaceMultiplication()
 
  188       return InPlaceMultiplication<Arg1,Arg2,!std::is_base_of<Base,Arg1>() && !std::is_base_of<Base,Arg2>() && !std::is_arithmetic<Arg1>() && !std::is_arithmetic<Arg2>()>::value;
 
  195     template < 
class Arg1 , 
class Arg2 >
 
  196     constexpr 
bool callToRightMultiply()
 
  198       return CallToRightMultiply<Arg1,Arg2,!std::is_base_of<Base,Arg1>() && !std::is_base_of<Base,Arg2>() && !std::is_arithmetic<Arg1>() && !std::is_arithmetic<Arg2>()>::value;
 
  205     template < 
class Arg >
 
  206     constexpr 
bool summation()
 
  208       return Summation<Arg,!std::is_base_of<Base,Arg>() && !std::is_arithmetic<Arg>()>::value;
 
  215     template < 
class Arg >
 
  216     constexpr 
bool inPlaceSummation()
 
  218       return InPlaceSummation<Arg,!std::is_base_of<Base,Arg>() && !std::is_arithmetic<Arg>()>::value;
 
  227     template < 
class Arg >
 
  228     constexpr 
bool isConstantSizeMatrix()
 
  230       return ( LinearAlgebra::numberOfRows<Arg>() > 0 ) && ( LinearAlgebra::numberOfColumns<Arg>() > 0 );
 
  239     template < 
class Arg >
 
  240     constexpr 
bool isStaticVector()
 
  242       return ( LinearAlgebra::numberOfRows<Arg>() > 0 ) && ( LinearAlgebra::numberOfColumns<Arg>() == -1 );
 
  249     template < 
class Arg >
 
  250     constexpr 
bool accessViaSquareBrackets()
 
  252       return std::conditional_t< !isConstantSizeMatrix<Arg>() && isStaticVector<Arg>() ,
 
  253                                  AccessViaSquareBracketsForVector<Arg> ,
 
  254                                  AccessViaSquareBracketsForMatrix<Arg> >::value;
 
  261     template < 
class Arg >
 
  262     constexpr 
bool accessViaRoundBrackets()
 
  264       return std::conditional_t< !isConstantSizeMatrix<Arg>() && isStaticVector<Arg>() ,
 
  265                                  AccessViaRoundBracketsForVector<Arg> ,
 
  266                                  AccessViaRoundBracketsForMatrix<Arg> >::value;
 
  274     constexpr 
bool hasUpdateFunction()
 
  276       return CallOfUpdate<F>::value;
 
  284     constexpr 
bool hasUpdateVariableFunction()
 
  286       return CallOfUpdateVariable<F>::value;
 
  291 #endif // RFFGEN_STATIC_CHECKS_HH 
typename Detail::voider< Types...>::type void_t
Most fascinating type ever. Is always void. 
Definition: voider.hh:40