12template<
template <
typename>
class Predicate,
unsigned n,
class Default,
class... Ts>
15template<
template <
typename>
class Predicate,
unsigned n,
class Default,
class T>
16struct find_if_impl<Predicate, n, Default, T>
18 using type = std::conditional_t< Predicate<T>::value, T, Default>;
19 static constexpr unsigned value = Predicate<T>::value ? n : n+1;
22template<
template <
typename>
class Predicate,
unsigned n,
class Default,
class T,
class... Ts>
23struct find_if_impl<Predicate, n, Default, T, Ts...>
25 using type = std::conditional_t< Predicate<T>::value, T,
typename find_if_impl<Predicate, n+1, Default, Ts...>::type>;
26 static constexpr unsigned value = Predicate<T>::value ? n : find_if_impl<Predicate, n+1, Default, Ts...>::value;
32template<
size_t index,
typename T,
typename... Ts>
33inline std::enable_if_t<index==0, T>
34get_idx(T&& t, Ts&&... ts) {
35 return std::forward<T>(t);
38template<
size_t index,
typename T,
typename... Ts>
39inline std::enable_if_t<(index > 0) && index <=
sizeof...(Ts),
40 std::tuple_element_t<index, std::tuple<T, Ts...>>>
41get_idx(T&& t, Ts&&... ts) {
42 return get_idx<index-1>(std::forward<Ts>(ts)...);
46template<
template <
typename>
class Predicate,
class Default,
class T,
class... Ts>
47using find_if_t =
typename detail::find_if_impl<Predicate,0, Default, T, Ts...>::type;
49template<
template <
typename>
class Predicate,
class Default,
class T,
class... Ts>
50using find_if_v = std::integral_constant<unsigned, detail::find_if_impl<Predicate,0, Default, T, Ts...>::value>;
59template<
class T,
class Tag = AnyScalarTag>
60using is_scalar =
typename std::is_base_of<Tag, get_tensor_category<T>>::type;
63template<
class T,
class Tag = AnyVectorTag>
64using is_vector =
typename std::is_base_of<Tag, get_tensor_category<T>>::type;
67template<
class T,
class Tag = AnyMatrixTag>
68using is_matrix =
typename std::is_base_of<Tag, get_tensor_category<T>>::type;
71template<
class T,
class Tag = AnyScalarTag>
74template<
class T,
class Tag = AnyVectorTag>
77template<
class T,
class Tag = AnyMatrixTag>
82template<
class T,
class Tag = AnyPolicyTag>
83using has_policy = std::is_same<Tag, get_execution_policy<T>>;
85template<
class T,
class Tag = AnyPolicyTag>
98template<
class T,
class Tag = AnyScalarTag>
99using is_not_scalar = std::conditional_t< !std::is_base_of<Tag, get_tensor_category<T>>::value, std::true_type, std::false_type>;
103template<
class Category>
104using find_base_category = std::conditional_t< std::is_base_of<SharedVectorTag, Category>::value,
SharedVectorTag,
108template<
class T,
class Category>
109using is_scalar_or_same_base_category = std::conditional_t< std::is_base_of<detail::find_base_category<Category>,
get_tensor_category<T>>::value ||
is_scalar<T>::value , std::true_type, std::false_type>;
114using has_not_any_policy = std::conditional_t< !std::is_same<AnyPolicyTag, get_execution_policy<T>>::value, std::true_type, std::false_type>;
116template<
class U,
class Policy>
117using has_any_or_same_policy = std::conditional_t< std::is_same<get_execution_policy<U>, Policy>::value || has_any_policy<U>::value, std::true_type, std::false_type>;
120using is_not_scalar_has_not_any_policy = std::conditional_t< !is_scalar<T>::value && !has_any_policy<T>::value, std::true_type, std::false_type>;
typename std::is_base_of< Tag, get_tensor_category< T > >::type is_vector
Does a type have a tensor_category derived from Tag.
Definition predicate.h:64
constexpr bool is_matrix_v
Utility typedef.
Definition predicate.h:78
constexpr bool is_scalar_v
Utility typedef.
Definition predicate.h:72
typename TensorTraits< std::decay_t< Vector > >::tensor_category get_tensor_category
Definition tensor_traits.h:47
typename std::is_base_of< Tag, get_tensor_category< T > >::type is_scalar
Does a type have a tensor_category derived from Tag.
Definition predicate.h:60
typename std::is_base_of< Tag, get_tensor_category< T > >::type is_matrix
Does a type have a tensor_category derived from Tag.
Definition predicate.h:68
std::is_same< Tag, get_execution_policy< T > > has_policy
Does a type have an execution_policy equal to Tag.
Definition predicate.h:83
constexpr bool is_vector_v
Utility typedef.
Definition predicate.h:75
constexpr bool has_policy_v
Utility typedef.
Definition predicate.h:86
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
A distributed vector contains a data container and a MPI communicator.
Definition vector_categories.h:52
This tag indicates composition/recursion.
Definition vector_categories.h:62
Indicate a contiguous chunk of shared memory.
Definition vector_categories.h:41
Definition predicate.h:94