Go to the documentation of this file.
11 #ifndef EIGEN_STATIC_ASSERT_H
12 #define EIGEN_STATIC_ASSERT_H
23 #ifndef EIGEN_STATIC_ASSERT
24 #ifndef EIGEN_NO_STATIC_ASSERT
26 #define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);
30 #define EIGEN_STATIC_ASSERT(CONDITION,MSG)
36 #define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE) \
37 EIGEN_STATIC_ASSERT(TYPE::IsVectorAtCompileTime, \
38 YOU_TRIED_CALLING_A_VECTOR_METHOD_ON_A_MATRIX)
41 #define EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE) \
42 EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime!=Eigen::Dynamic, \
43 YOU_CALLED_A_FIXED_SIZE_METHOD_ON_A_DYNAMIC_SIZE_MATRIX_OR_VECTOR)
46 #define EIGEN_STATIC_ASSERT_DYNAMIC_SIZE(TYPE) \
47 EIGEN_STATIC_ASSERT(TYPE::SizeAtCompileTime==Eigen::Dynamic, \
48 YOU_CALLED_A_DYNAMIC_SIZE_METHOD_ON_A_FIXED_SIZE_MATRIX_OR_VECTOR)
51 #define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE) \
52 EIGEN_STATIC_ASSERT(TYPE::IsVectorAtCompileTime && TYPE::SizeAtCompileTime==SIZE, \
53 THIS_METHOD_IS_ONLY_FOR_VECTORS_OF_A_SPECIFIC_SIZE)
56 #define EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(TYPE, ROWS, COLS) \
57 EIGEN_STATIC_ASSERT(TYPE::RowsAtCompileTime==ROWS && TYPE::ColsAtCompileTime==COLS, \
58 THIS_METHOD_IS_ONLY_FOR_MATRICES_OF_A_SPECIFIC_SIZE)
61 #define EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(TYPE0,TYPE1) \
62 EIGEN_STATIC_ASSERT( \
63 (int(TYPE0::SizeAtCompileTime)==Eigen::Dynamic \
64 || int(TYPE1::SizeAtCompileTime)==Eigen::Dynamic \
65 || int(TYPE0::SizeAtCompileTime)==int(TYPE1::SizeAtCompileTime)),\
66 YOU_MIXED_VECTORS_OF_DIFFERENT_SIZES)
68 #define EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1) \
70 (int(Eigen::internal::size_of_xpr_at_compile_time<TYPE0>::ret)==0 && int(Eigen::internal::size_of_xpr_at_compile_time<TYPE1>::ret)==0) \
72 (int(TYPE0::RowsAtCompileTime)==Eigen::Dynamic \
73 || int(TYPE1::RowsAtCompileTime)==Eigen::Dynamic \
74 || int(TYPE0::RowsAtCompileTime)==int(TYPE1::RowsAtCompileTime)) \
75 && (int(TYPE0::ColsAtCompileTime)==Eigen::Dynamic \
76 || int(TYPE1::ColsAtCompileTime)==Eigen::Dynamic \
77 || int(TYPE0::ColsAtCompileTime)==int(TYPE1::ColsAtCompileTime))\
81 #define EIGEN_STATIC_ASSERT_NON_INTEGER(TYPE) \
82 EIGEN_STATIC_ASSERT(!Eigen::NumTraits<TYPE>::IsInteger, THIS_FUNCTION_IS_NOT_FOR_INTEGER_NUMERIC_TYPES)
86 #define EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(TYPE0,TYPE1) \
87 EIGEN_STATIC_ASSERT( \
88 EIGEN_PREDICATE_SAME_MATRIX_SIZE(TYPE0,TYPE1),\
89 YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES)
91 #define EIGEN_STATIC_ASSERT_SIZE_1x1(TYPE) \
92 EIGEN_STATIC_ASSERT((TYPE::RowsAtCompileTime == 1 || TYPE::RowsAtCompileTime == Eigen::Dynamic) && \
93 (TYPE::ColsAtCompileTime == 1 || TYPE::ColsAtCompileTime == Eigen::Dynamic), \
94 THIS_METHOD_IS_ONLY_FOR_1x1_EXPRESSIONS)
96 #define EIGEN_STATIC_ASSERT_LVALUE(Derived) \
97 EIGEN_STATIC_ASSERT(Eigen::internal::is_lvalue<Derived>::value, \
98 THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY)
100 #define EIGEN_STATIC_ASSERT_ARRAYXPR(Derived) \
101 EIGEN_STATIC_ASSERT((Eigen::internal::is_same<typename Eigen::internal::traits<Derived>::XprKind, ArrayXpr>::value), \
102 THIS_METHOD_IS_ONLY_FOR_ARRAYS_NOT_MATRICES)
104 #define EIGEN_STATIC_ASSERT_SAME_XPR_KIND(Derived1, Derived2) \
105 EIGEN_STATIC_ASSERT((Eigen::internal::is_same<typename Eigen::internal::traits<Derived1>::XprKind, \
106 typename Eigen::internal::traits<Derived2>::XprKind \
108 YOU_CANNOT_MIX_ARRAYS_AND_MATRICES)
112 #define EIGEN_INTERNAL_CHECK_COST_VALUE(C) \
113 EIGEN_STATIC_ASSERT((C)>=0 && (C)<=HugeCost*HugeCost, EIGEN_INTERNAL_ERROR_PLEASE_FILE_A_BUG_REPORT__INVALID_COST_VALUE);