3#ifndef DUNE_COMMON_CONCEPT_HH
4#define DUNE_COMMON_CONCEPT_HH
11#include <dune/common/typelist.hh>
13#include <dune/common/std/type_traits.hh>
44template<
class... BaseConcepts>
60 template<
class C,
class... T>
77 template<
class C,
class... T,
78 decltype(std::declval<C>().require(std::declval<T>()...), 0) =0>
85 template<
class C,
class... T>
86 constexpr std::false_type matchesRequirement(PriorityTag<0>)
93 constexpr bool modelsConceptList(TypeList<>)
99 template<
class...T,
class C0,
class... CC>
100 constexpr bool modelsConceptList(TypeList<C0, CC...>)
101 {
return Imp::models<C0, T...>() and modelsConceptList<T...>(TypeList<CC...>()); }
107 template<
class C,
class... T>
108 constexpr bool modelsConcept(PriorityTag<0>)
109 {
return matchesRequirement<C, T...>(PriorityTag<42>()); }
117 template<
class C,
class... T,
118 decltype(
typename C::BaseConceptList(), 0) = 0>
119 constexpr bool modelsConcept(PriorityTag<1>)
120 {
return matchesRequirement<C, T...>(PriorityTag<42>()) and modelsConceptList<T...>(
typename C::BaseConceptList()); }
131 template<
class C,
class... T>
134 return modelsConcept<C, T...>(PriorityTag<42>());
171template<
class C,
class... T>
174 return Std::bool_constant<Concept::Imp::models<C, T...>()>();
188 template<
class C,
class Tuple>
189 struct TupleEntriesModelHelper
191 template<
class Accumulated,
class T>
192 struct AccumulateFunctor
194 using type =
typename std::integral_constant<bool, Accumulated::value and models<C, T>()>;
208template<
class C,
class Tuple>
209constexpr auto tupleEntriesModel()
210 ->
typename Imp::TupleEntriesModelHelper<C, Tuple>::Result
223template<bool b, typename std::enable_if<b, int>::type = 0>
224constexpr bool requireTrue()
230template<
class C,
class... T,
typename std::enable_if<
models<C, T...>(),
int>::type = 0>
231constexpr bool requireConcept()
238template<
class C,
class... T,
typename std::enable_if<
models<C, T...>(),
int>::type = 0>
239constexpr bool requireConcept(T&&... t)
246template<class C, class Tuple, typename std::enable_if<tupleEntriesModel<C, Tuple>(),
int>::type = 0>
247constexpr bool requireConceptForTupleEntries()
254template<
class From,
class To,
255 typename std::enable_if< std::is_convertible<From, To>::value,
int>::type = 0>
256constexpr bool requireConvertible()
263template<
class To,
class From,
264 typename std::enable_if< std::is_convertible<From, To>::value,
int>::type = 0>
265constexpr bool requireConvertible(
const From&)
275constexpr bool requireType()
282template<
class Base,
class Derived,
283 typename std::enable_if< std::is_base_of<Base, Derived>::value,
int>::type = 0>
284constexpr bool requireBaseOf()
291template<
class Base,
class Derived,
292 typename std::enable_if< std::is_base_of<Base, Derived>::value,
int>::type = 0>
293constexpr bool requireBaseOf(
const Derived&)
300template<
class A,
class B,
301 typename std::enable_if< std::is_same<A, B>::value,
int>::type = 0>
302constexpr bool requireSameType()
F< Accumulated, Value >::type type
Result of the reduce operation.
Definition: tupleutility.hh:605
Dune namespace.
Definition: alignment.hh:11
constexpr auto models()
Check if concept is modeled by given types.
Definition: concept.hh:172
Base class for refined concepts.
Definition: concept.hh:46
Helper class for tagging priorities.
Definition: typeutilities.hh:60
A simple type list.
Definition: typelist.hh:31
Contains utility classes which can be used with std::tuple.
Utilities for type computations, constraining overloads, ...