1#ifndef __DUNE_ACFEM_EXPRESSIONS_EXPRESSIONTRAITS_HH__
2#define __DUNE_ACFEM_EXPRESSIONS_EXPRESSIONTRAITS_HH__
9#include "../common/types.hh"
38 DefaultTraitsLevel = 0
41 , TopTraitsLevel = Expressions::Policy::TraitsLevelMax::value
42 , Primary = TopTraitsLevel
43 , Secondary = (int)TopTraitsLevel - 1
51 std::size_t Priority = TopTraitsLevel>
66 using ExpressionType = void;
68 static constexpr bool isOne =
false;
69 static constexpr bool isMinusOne =
false;
71 static constexpr bool isVolatile =
false;
72 static constexpr bool isIndependent =
false;
74 static constexpr bool isTypedValue =
false;
83 std::enable_if_t<!IsDecay<T>::value>,
100 using ExpressionType = std::decay<T>;
101 static constexpr bool isNonZero =
false;
102 static constexpr bool isNonSingular =
false;
103 static constexpr bool isZero =
true;
104 static constexpr bool isOne =
false;
105 static constexpr bool isMinusOne =
false;
106 static constexpr bool isSemiPositive =
true;
107 static constexpr bool isSemiNegative =
true;
108 static constexpr bool isPostive =
false;
109 static constexpr bool isNegative =
false;
111 static constexpr bool isVolatile =
false;
112 static constexpr bool isIndependent =
true;
113 static constexpr bool isConstant =
true;
114 static constexpr bool isTypedValue =
true;
126 template<
class T,
class SFINAE =
void>
127 struct OwnsExpressionTraits
132 struct OwnsExpressionTraits<
134 std::enable_if_t<(std::is_class<std::decay_t<T> >::value &&
135 SameDecay<T, typename ExpressionTraits<T>::ExpressionType>::value)> >
139 template<
class Expression,
class Int, Int I>
140 constexpr std::enable_if_t<OwnsExpressionTraits<Expression>::value,
bool>
141 operator<=(
const Expression&, Constant<Int, I>)
143 return ExpressionTraits<Expression>::isSemiNegative && I >= 0;
146 template<
class Expression,
class Int, Int I>
147 constexpr std::enable_if_t<OwnsExpressionTraits<Expression>::value,
bool>
148 operator>=(
const Expression&, Constant<Int, I>)
150 return ExpressionTraits<Expression>::isSemiPositive && I <= 0;
153 template<
class Expression,
class Int, Int I>
154 constexpr std::enable_if_t<OwnsExpressionTraits<Expression>::value,
bool>
155 operator<(
const Expression&, Constant<Int, I>)
157 return ExpressionTraits<Expression>::isNegative && I >= 0;
160 template<
class Expression,
class Int, Int I>
161 constexpr std::enable_if_t<OwnsExpressionTraits<Expression>::value,
bool>
162 operator>(
const Expression&, Constant<Int, I>)
164 return ExpressionTraits<Expression>::isPositive && I <= 0;
167 template<
class Expression,
class Int, Int I>
168 constexpr std::enable_if_t<OwnsExpressionTraits<Expression>::value,
bool>
169 operator==(
const Expression&, Constant<Int, I>)
171 return ExpressionTraits<Expression>::isZero && I == 0;
174 template<
class Expression,
class Int, Int I>
175 constexpr std::enable_if_t<OwnsExpressionTraits<Expression>::value,
bool>
176 operator!=(
const Expression&, Constant<Int, I>)
178 return ExpressionTraits<Expression>::isZero && I != 0;
182 constexpr auto expressionTraits()
184 return ExpressionTraits<T>{};
188 constexpr auto expressionTraits(T&&)
190 return expressionTraits<T>();
BoolConstant< std::is_reference< T >::value &&IsTypedValue< T >::value > IsTypedValueReference
Compile-time true if T is a reference to a "typed value".
Definition: expressiontraits.hh:94
BoolConstant< ExpressionTraits< T >::isTypedValue > IsTypedValue
Compile-time true if T is a "typed value", e.g. a std::integral_constant.
Definition: expressiontraits.hh:90
constexpr bool isConstant(Sequence< T, T0, Ts... >)
Definition: compare.hh:285
Constant< bool, V > BoolConstant
Short-cut for integral constant of type bool.
Definition: types.hh:48
BoolConstant< false > FalseType
Alias for std::false_type.
Definition: types.hh:110
BoolConstant< true > TrueType
Alias for std::true_type.
Definition: types.hh:107
Default expression traits definition is a recursion in order to ease disambiguation.
Definition: expressiontraits.hh:54
A class mainting the sign of an expression during operations.
Definition: sign.hh:30
ExpressionTraits for any zero-expression.
Definition: expressiontraits.hh:99