5#ifndef DUNE_COMMON_CONCEPT_HH
6#define DUNE_COMMON_CONCEPT_HH
13#include <dune/common/typelist.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>
202 template<
class C,
class Tuple>
203 struct TupleEntriesModelHelper
205 template<
class Accumulated,
class T>
206 struct AccumulateFunctor
208 using type =
typename std::integral_constant<bool, Accumulated::value and models<C, T>()>;
223template<
class C,
class Tuple>
224constexpr auto tupleEntriesModel()
225 ->
typename Impl::TupleEntriesModelHelper<C, Tuple>::Result
238template<bool b, typename std::enable_if<b, int>::type = 0>
239constexpr bool requireTrue()
245template<
class C,
class... T,
typename std::enable_if<
models<C, T...>(),
int>::type = 0>
246constexpr bool requireConcept()
253template<
class C,
class... T,
typename std::enable_if<
models<C, T...>(),
int>::type = 0>
254constexpr bool requireConcept(T&&... )
261template<class C, class Tuple, typename std::enable_if<tupleEntriesModel<C, Tuple>(),
int>::type = 0>
262constexpr bool requireConceptForTupleEntries()
269template<
class From,
class To,
270 typename std::enable_if< std::is_convertible<From, To>::value,
int>::type = 0>
271constexpr bool requireConvertible()
278template<
class To,
class From,
279 typename std::enable_if< std::is_convertible<From, To>::value,
int>::type = 0>
280constexpr bool requireConvertible(
const From&)
290constexpr bool requireType()
297template<
class Base,
class Derived,
298 typename std::enable_if< std::is_base_of<Base, Derived>::value,
int>::type = 0>
299constexpr bool requireBaseOf()
306template<
class Base,
class Derived,
307 typename std::enable_if< std::is_base_of<Base, Derived>::value,
int>::type = 0>
308constexpr bool requireBaseOf(
const Derived&)
315template<
class A,
class B,
316 typename std::enable_if< std::is_same<A, B>::value,
int>::type = 0>
317constexpr bool requireSameType()
constexpr auto models()
Check if concept is modeled by given types.
Definition: concept.hh:184
F< Accumulated, Value >::type type
Result of the reduce operation.
Definition: tupleutility.hh:522
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
Contains utility classes which can be used with std::tuple.
Utilities for type computations, constraining overloads, ...