5#ifndef DUNE_COMMON_CONCEPT_HH
6#define DUNE_COMMON_CONCEPT_HH
13#include <dune/common/typelist.hh>
14#include <dune/common/indices.hh>
15#include <dune/common/std/type_traits.hh>
52template<
class... BaseConcepts>
55 typedef TypeList<BaseConcepts...> BaseConceptList;
69 template<
class C,
class... T>
86 template<
class C,
class... T,
87 decltype(std::declval<C>().require(std::declval<T>()...), 0) =0>
94 template<
class C,
class... T>
95 constexpr std::false_type matchesRequirement(PriorityTag<0>)
102 constexpr bool modelsConceptList(TypeList<>)
108 template<
class...T,
class C0,
class... CC>
109 constexpr bool modelsConceptList(TypeList<C0, CC...>)
110 {
return models<C0, T...>() and modelsConceptList<T...>(TypeList<CC...>()); }
116 template<
class C,
class... T>
117 constexpr bool modelsConcept(PriorityTag<0>)
118 {
return matchesRequirement<C, T...>(PriorityTag<42>()); }
126 template<
class C,
class... T,
127 decltype(
typename C::BaseConceptList(), 0) = 0>
128 constexpr bool modelsConcept(PriorityTag<1>)
129 {
return matchesRequirement<C, T...>(PriorityTag<42>()) and modelsConceptList<T...>(
typename C::BaseConceptList()); }
140 template<
class C,
class... T>
143 return modelsConcept<C, T...>(PriorityTag<42>());
183template<
class C,
class... T>
198template<
class C,
class Tuple>
199constexpr auto tupleEntriesModel()
202 return std::conjunction<
decltype(
Dune::models<C, std::tuple_element_t<
decltype(i)::value, Tuple>>())...>();
203 }, std::make_index_sequence<std::tuple_size_v<Tuple>>());
214template<bool b, typename std::enable_if<b, int>::type = 0>
215constexpr bool requireTrue()
221template<
class C,
class... T,
typename std::enable_if<
models<C, T...>(),
int>::type = 0>
222constexpr bool requireConcept()
229template<
class C,
class... T,
typename std::enable_if<
models<C, T...>(),
int>::type = 0>
230constexpr bool requireConcept(T&&... )
237template<class C, class Tuple, typename std::enable_if<tupleEntriesModel<C, Tuple>(),
int>::type = 0>
238constexpr bool requireConceptForTupleEntries()
245template<
class From,
class To,
246 typename std::enable_if< std::is_convertible<From, To>::value,
int>::type = 0>
247constexpr bool requireConvertible()
254template<
class To,
class From,
255 typename std::enable_if< std::is_convertible<From, To>::value,
int>::type = 0>
256constexpr bool requireConvertible(
const From&)
266constexpr bool requireType()
273template<
class Base,
class Derived,
274 typename std::enable_if< std::is_base_of<Base, Derived>::value,
int>::type = 0>
275constexpr bool requireBaseOf()
282template<
class Base,
class Derived,
283 typename std::enable_if< std::is_base_of<Base, Derived>::value,
int>::type = 0>
284constexpr bool requireBaseOf(
const Derived&)
291template<
class A,
class B,
292 typename std::enable_if< std::is_same<A, B>::value,
int>::type = 0>
293constexpr bool requireSameType()
decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, i... > sequence)
Unpack an std::integer_sequence<I,i...> to std::integral_constant<I,i>...
Definition: indices.hh:124
constexpr auto models()
Check if concept is modeled by given types.
Definition: concept.hh:184
std::tuple< MetaType< T >... > TypeList
A simple type list.
Definition: typelist.hh:87
Dune namespace.
Definition: alignedallocator.hh:13
Base class for refined concepts.
Definition: concept.hh:54
Helper class for tagging priorities.
Definition: typeutilities.hh:73
Utilities for type computations, constraining overloads, ...