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>
48template<
class... BaseConcepts>
51 typedef TypeList<BaseConcepts...> BaseConceptList;
65 template<
class C,
class... T>
82 template<
class C,
class... T,
83 decltype(std::declval<C>().require(std::declval<T>()...), 0) =0>
90 template<
class C,
class... T>
91 constexpr std::false_type matchesRequirement(PriorityTag<0>)
98 constexpr bool modelsConceptList(TypeList<>)
104 template<
class...T,
class C0,
class... CC>
105 constexpr bool modelsConceptList(TypeList<C0, CC...>)
106 {
return models<C0, T...>() and modelsConceptList<T...>(TypeList<CC...>()); }
112 template<
class C,
class... T>
113 constexpr bool modelsConcept(PriorityTag<0>)
114 {
return matchesRequirement<C, T...>(PriorityTag<42>()); }
122 template<
class C,
class... T,
123 decltype(
typename C::BaseConceptList(), 0) = 0>
124 constexpr bool modelsConcept(PriorityTag<1>)
125 {
return matchesRequirement<C, T...>(PriorityTag<42>()) and modelsConceptList<T...>(
typename C::BaseConceptList()); }
136 template<
class C,
class... T>
139 return modelsConcept<C, T...>(PriorityTag<42>());
179template<
class C,
class... T>
198 template<
class C,
class Tuple>
199 struct TupleEntriesModelHelper
201 template<
class Accumulated,
class T>
202 struct AccumulateFunctor
204 using type =
typename std::integral_constant<bool, Accumulated::value and models<C, T>()>;
219template<
class C,
class Tuple>
220constexpr auto tupleEntriesModel()
221 ->
typename Impl::TupleEntriesModelHelper<C, Tuple>::Result
234template<bool b, typename std::enable_if<b, int>::type = 0>
235constexpr bool requireTrue()
241template<
class C,
class... T,
typename std::enable_if<
models<C, T...>(),
int>::type = 0>
242constexpr bool requireConcept()
249template<
class C,
class... T,
typename std::enable_if<
models<C, T...>(),
int>::type = 0>
250constexpr bool requireConcept(T&&... )
257template<class C, class Tuple, typename std::enable_if<tupleEntriesModel<C, Tuple>(),
int>::type = 0>
258constexpr bool requireConceptForTupleEntries()
265template<
class From,
class To,
266 typename std::enable_if< std::is_convertible<From, To>::value,
int>::type = 0>
267constexpr bool requireConvertible()
274template<
class To,
class From,
275 typename std::enable_if< std::is_convertible<From, To>::value,
int>::type = 0>
276constexpr bool requireConvertible(
const From&)
286constexpr bool requireType()
293template<
class Base,
class Derived,
294 typename std::enable_if< std::is_base_of<Base, Derived>::value,
int>::type = 0>
295constexpr bool requireBaseOf()
302template<
class Base,
class Derived,
303 typename std::enable_if< std::is_base_of<Base, Derived>::value,
int>::type = 0>
304constexpr bool requireBaseOf(
const Derived&)
311template<
class A,
class B,
312 typename std::enable_if< std::is_same<A, B>::value,
int>::type = 0>
313constexpr bool requireSameType()
constexpr auto models()
Check if concept is modeled by given types.
Definition: concept.hh:180
std::integral_constant< bool, value > bool_constant
A template alias for std::integral_constant<bool, value>
Definition: type_traits.hh:118
F< Accumulated, Value >::type type
Result of the reduce operation.
Definition: tupleutility.hh:539
std::tuple< MetaType< T >... > TypeList
A simple type list.
Definition: typelist.hh:85
Dune namespace.
Definition: alignedallocator.hh:10
Base class for refined concepts.
Definition: concept.hh:50
Helper class for tagging priorities.
Definition: typeutilities.hh:71
Contains utility classes which can be used with std::tuple.
Utilities for type computations, constraining overloads, ...