dune-fem 2.8.0
Loading...
Searching...
No Matches
policies.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_GRIDPART_COMMON_POLICIES_HH
2#define DUNE_FEM_GRIDPART_COMMON_POLICIES_HH
3
4#include <type_traits>
5#include <utility>
6
7#include <dune/grid/common/gridview.hh>
8
10
11namespace Dune
12{
13
14 namespace Fem
15 {
16
17 // Internal forward declaration
18 // ----------------------------
19
20 template< class Traits >
21 class GridPartPolicies;
22
23
24
25#ifndef DOXYGEN
26
27 namespace __GridPartPolicies
28 {
29
30 // hasGridView
31 // -----------
32
33 template< class Traits >
34 std::true_type __hasGridView ( const Traits &, const typename Traits::GridViewType * = nullptr );
35
36 std::false_type __hasGridView ( ... );
37
38 template< class Traits >
39 struct hasGridView
40 {
41 static const bool v = decltype( __hasGridView( std::declval< Traits >() ) )::value;
42 };
43
44
45
46 // HasGridView
47 // -----------
48
49 template< class Traits, bool hasGridView = hasGridView< Traits >::v >
50 class HasGridView;
51
52 template< class Traits >
53 class HasGridView< Traits, true >
54 {
55 public:
56 typedef typename Traits::GridViewType GridViewType;
57 };
58
59 template< class Traits >
60 class HasGridView< Traits, false >
61 {
62 typedef typename Traits::GridPartType GridPartType;
63
64 public:
65 typedef Dune::GridView< GridPart2GridViewTraits< GridPartType > > GridViewType;
66
67 protected:
68 HasGridView () = default;
69
70 public:
71 operator GridPart2GridViewImpl< GridPartType > () const
72 {
73 return GridPart2GridViewImpl< GridPartType >( impl() );
74 }
75
76 private:
77 const GridPartType &impl () const
78 {
79 return static_cast< const GridPartType & >( *this );
80 }
81 };
82
83 } // namespace __GridPartPolicies
84
85#endif // #ifndef DOXYGEN
86
87
88
89 // GridPartPolicies
90 // ----------------
91
92 template< class Traits >
94 : public __GridPartPolicies::HasGridView< Traits >
95 {};
96
97 } // namespace Fem
98
99} // namespace Dune
100
101#endif // #ifndef DUNE_FEM_GRIDPART_COMMON_POLICIES_HH
Definition: bindguard.hh:11
Definition: policies.hh:95