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>
50template<
class... BaseConcepts>
53 typedef TypeList<BaseConcepts...> BaseConceptList;
67 template<
class C,
class... T>
84 template<
class C,
class... T,
85 decltype(std::declval<C>().require(std::declval<T>()...), 0) =0>
92 template<
class C,
class... T>
93 constexpr std::false_type matchesRequirement(PriorityTag<0>)
100 constexpr bool modelsConceptList(TypeList<>)
106 template<
class...T,
class C0,
class... CC>
107 constexpr bool modelsConceptList(TypeList<C0, CC...>)
108 {
return models<C0, T...>() and modelsConceptList<T...>(TypeList<CC...>()); }
114 template<
class C,
class... T>
115 constexpr bool modelsConcept(PriorityTag<0>)
116 {
return matchesRequirement<C, T...>(PriorityTag<42>()); }
124 template<
class C,
class... T,
125 decltype(
typename C::BaseConceptList(), 0) = 0>
126 constexpr bool modelsConcept(PriorityTag<1>)
127 {
return matchesRequirement<C, T...>(PriorityTag<42>()) and modelsConceptList<T...>(
typename C::BaseConceptList()); }
138 template<
class C,
class... T>
141 return modelsConcept<C, T...>(PriorityTag<42>());
181template<
class C,
class... T>
200 template<
class C,
class Tuple>
201 struct TupleEntriesModelHelper
203 template<
class Accumulated,
class T>
204 struct AccumulateFunctor
206 using type =
typename std::integral_constant<bool, Accumulated::value and models<C, T>()>;
221template<
class C,
class Tuple>
222constexpr auto tupleEntriesModel()
223 ->
typename Impl::TupleEntriesModelHelper<C, Tuple>::Result
236template<bool b, typename std::enable_if<b, int>::type = 0>
237constexpr bool requireTrue()
243template<
class C,
class... T,
typename std::enable_if<
models<C, T...>(),
int>::type = 0>
244constexpr bool requireConcept()
251template<
class C,
class... T,
typename std::enable_if<
models<C, T...>(),
int>::type = 0>
252constexpr bool requireConcept(T&&... )
259template<class C, class Tuple, typename std::enable_if<tupleEntriesModel<C, Tuple>(),
int>::type = 0>
260constexpr bool requireConceptForTupleEntries()
267template<
class From,
class To,
268 typename std::enable_if< std::is_convertible<From, To>::value,
int>::type = 0>
269constexpr bool requireConvertible()
276template<
class To,
class From,
277 typename std::enable_if< std::is_convertible<From, To>::value,
int>::type = 0>
278constexpr bool requireConvertible(
const From&)
288constexpr bool requireType()
295template<
class Base,
class Derived,
296 typename std::enable_if< std::is_base_of<Base, Derived>::value,
int>::type = 0>
297constexpr bool requireBaseOf()
304template<
class Base,
class Derived,
305 typename std::enable_if< std::is_base_of<Base, Derived>::value,
int>::type = 0>
306constexpr bool requireBaseOf(
const Derived&)
313template<
class A,
class B,
314 typename std::enable_if< std::is_same<A, B>::value,
int>::type = 0>
315constexpr bool requireSameType()
constexpr auto models()
Check if concept is modeled by given types.
Definition: concept.hh:182
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:520
std::tuple< MetaType< T >... > TypeList
A simple type list.
Definition: typelist.hh:87
Dune namespace.
Definition: alignedallocator.hh:14
Base class for refined concepts.
Definition: concept.hh:52
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, ...