1#ifndef DUNE_FEM_COMMON_UTILITY_HH
2#define DUNE_FEM_COMMON_UTILITY_HH
32 template<
class T, std::enable_if_t< std::is_arithmetic< std::decay_t< T > >::value,
int > = 0 >
33 static constexpr std::decay_t< T > sum ( T a )
38 template<
class T, T a >
39 static constexpr std::decay_t< T > sum ( std::integral_constant< T, a > )
44 template<
class T, std::enable_if_t< std::is_enum< std::decay_t< T > >::value,
int > = 0 >
45 static constexpr std::underlying_type_t< std::decay_t< T > > sum ( T a )
50 template<
class T,
class ... U >
51 static constexpr auto sum ( T a, U ... b )
53 return a + sum( b ... );
61 static constexpr T sub ( T a )
66 template<
class T,
class ... U >
67 static constexpr T sub ( T a, U ... b )
69 return a - sub( b ... );
77 static constexpr T
max ( T a )
82 template<
class T,
class ... U >
83 static constexpr T
max ( T a, U ... b )
85 return a >
max( b ... )? a :
max( b ... );
93 static constexpr T
min ( T a )
98 template<
class T,
class ... U >
99 static constexpr T
min ( T a, U ... b )
101 return a <
min( b ... )? a :
min( b ... );
110 static constexpr bool Or ()
115 template <
class ... U >
116 static constexpr bool Or (
bool a, U ... b )
118 return a || Or( b ... );
125 static constexpr bool And ()
130 template<
class B,
class ... U >
131 static constexpr bool And ( B a, U ... b )
133 return a && And( b... );
146 template<
class ... T >
150 struct are_all_same< T > :
public std::true_type {};
152 template<
class U,
class V,
class ... T >
153 struct are_all_same< U, V, T ... >
154 :
public std::integral_constant< bool, std::is_same< U, V >::value &&are_all_same< V, T ... >::value >
161 :
public std::integral_constant<bool, std::is_standard_layout<T>::value && std::is_trivial<T>::value>
172 template <
class Obj,
int defaultValue = -1 >
176 template <
typename T,
typename =
int>
177 struct CheckPointSetId :
public std::false_type { };
179 template <
typename T>
180 struct CheckPointSetId<T, decltype((void) T::pointSetId, 0)> :
public std::true_type { };
182 template <
class T,
bool>
183 struct SelectValue {
static const int value = defaultValue; };
186 struct SelectValue< T, true > {
static const int value = T::pointSetId; };
188 static constexpr int value = SelectValue< Obj, CheckPointSetId< Obj >::value >::value;
192 template <
class SFS,
bool defaultValue = false >
196 template <
typename T,
typename =
int>
197 struct CheckCodegenSFS :
public std::false_type { };
199 template <
typename T>
200 struct CheckCodegenSFS<T, decltype((void) T::codegenShapeFunctionSet, 0)> :
public std::true_type { };
202 template <
class T,
bool>
203 struct SelectValue {
static const bool value = defaultValue; };
206 struct SelectValue< T, true > {
static const bool value = T::codegenShapeFunctionSet; };
208 static constexpr int value = SelectValue< SFS, CheckCodegenSFS< SFS >::value >::value;
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:484
constexpr auto min
Function object that returns the smaller of the given values.
Definition: hybridutilities.hh:506
Dune namespace.
Definition: alignedallocator.hh:13
selects SFS::codegenShapeFunctionSet if available, otherwise defaultValue (default is false)
Definition: utility.hh:194
selects Obj::pointSetId if available, otherwise defaultValue (default is -1)
Definition: utility.hh:174