AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
ConceptsBase.hpp
1#pragma once
2
3#include <type_traits>
4#include <dune/common/typetraits.hh>
5
6#define AMDIS_CONCAT_IMPL( x, y ) x##y
7#define AMDIS_MACRO_CONCAT( x, y ) AMDIS_CONCAT_IMPL( x, y )
8
9#ifdef DOXYGEN
10 #define REQUIRES(...)
11 #define REQUIRES_(...)
12 #define CONCEPT constexpr
13 #define CHECK_CONCEPT(...)
14#else
15 #define REQUIRES(...) std::enable_if_t<__VA_ARGS__ , int> = 0
16 #define REQUIRES_(...) std::enable_if_t<__VA_ARGS__ , int>
17 #define CONCEPT constexpr
18 #define CHECK_CONCEPT(...) static __VA_ARGS__ AMDIS_MACRO_CONCAT( _concept_check_, __COUNTER__ )
19#endif
20
21namespace AMDiS
22{
23 namespace Concepts
24 {
25 namespace Impl_
26 {
27 template <class Concept, class = std::void_t<>>
28 struct models
29 : std::false_type
30 {};
31
32 template <class Concept, class... Ts>
33 struct models<Concept(Ts...), std::void_t< decltype(std::declval<Concept>().require(std::declval<Ts>()...)) >>
34 : std::true_type
35 {};
36
37 } // end namespace Impl_
38
39
40#ifndef DOXYGEN
41 template <class Concept>
42 constexpr bool models = Impl_::models<Concept>::value;
43
44 template <class Concept>
45 using models_t = Impl_::models<Concept>;
46#endif // DOXYGEN
47
48 } // end namespace Concepts
49} // end namespace AMDiS