TagTraits.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <type_traits>
7 
8 /// \cond
9 namespace db {
10 struct SimpleTag;
11 struct BaseTag;
12 struct ComputeTag;
13 struct ReferenceTag;
14 } // namespace db
15 /// \endcond
16 
17 namespace db {
18 /*!
19  * \ingroup DataBoxGroup
20  * \brief Check if `Tag` derives off of db::ComputeTag.
21  *
22  * \see is_compute_tag_v ComputeTag
23  */
24 template <typename Tag>
25 struct is_compute_tag : std::is_base_of<db::ComputeTag, Tag> {};
26 
27 /// \ingroup DataBoxGroup
28 /// \brief True if `Tag` derives from db::ComputeTag.
29 template <typename Tag>
31 
32 /*!
33  * \ingroup DataBoxGroup
34  * \brief Check if `Tag` derives off of db::ReferenceTag.
35  *
36  * \see is_reference_tag_v ReferenceTag
37  */
38 template <typename Tag>
39 struct is_reference_tag : std::is_base_of<db::ReferenceTag, Tag> {};
40 
41 /// \ingroup DataBoxGroup
42 /// \brief True if `Tag` derives from db::ReferenceTag.
43 template <typename Tag>
45 
46 /*!
47  * \ingroup DataBoxGroup
48  * \brief Check if `Tag` is a DataBox tag for an immutable item, i.e. a
49  * ComputeTag or ReferenceTag
50  *
51  * \see is_immutable_item_tag_v
52  */
53 template <typename Tag>
55  : std::bool_constant<std::is_base_of_v<db::ReferenceTag, Tag> or
56  std::is_base_of_v<db::ComputeTag, Tag>> {};
57 
58 /// \ingroup DataBoxGroup
59 /// \brief True if `Tag` is a DataBox tag for an immutable item, i.e. a
60 /// ComputeTag or ReferenceTag.
61 template <typename Tag>
63 
64 /*!
65  * \ingroup DataBoxGroup
66  * \brief Check if `Tag` is a DataBox tag for a mutable item, i.e. a SimpleTag
67  *
68  * \see is_mutable_item_tag_v
69  */
70 template <typename Tag>
72  : std::bool_constant<std::is_base_of_v<db::SimpleTag, Tag> and
73  not is_compute_tag_v<Tag> and
74  not is_reference_tag_v<Tag>> {};
75 
76 /// \ingroup DataBoxGroup
77 /// \brief True if `Tag` is a DataBox tag for a mutable item, i.e. a SimpleTag
78 template <typename Tag>
80 
81 /*!
82  * \ingroup DataBoxGroup
83  * \brief Check if `Tag` is a simple tag.
84  *
85  * \details This is done by deriving from std::true_type if `Tag` is derived
86  * from db::SimpleTag, but not from db::ComputeTag or db::ReferenceTag.
87  *
88  * \see is_simple_tag_v SimpleTag
89  */
90 template <typename Tag>
92  : std::bool_constant<std::is_base_of_v<db::SimpleTag, Tag> and
93  not is_compute_tag_v<Tag> and
94  not is_reference_tag_v<Tag>> {};
95 
96 /// \ingroup DataBoxGroup
97 /// \brief True if `Tag` is a simple tag.
98 template <typename Tag>
100 
101 /*!
102  * \ingroup DataBoxGroup
103  * \brief Check if `Tag` is not a base tag.
104  *
105  * \see is_non_base_tag_v BaseTag
106  */
107 template <typename Tag>
108 struct is_non_base_tag : std::is_base_of<db::SimpleTag, Tag> {};
109 
110 /// \ingroup DataBoxGroup
111 /// \brief True if `Tag` is not a base tag.
112 template <typename Tag>
114 
115 /*!
116  * \ingroup DataBoxGroup
117  * \brief Check if `Tag` is a DataBox tag, i.e. a BaseTag, SimpleTag,
118  * ComputeTag, or ReferenceTag.
119  *
120  * \see is_tag_v
121  */
122 template <typename Tag>
123 struct is_tag : std::bool_constant<std::is_base_of_v<db::SimpleTag, Tag> or
124  std::is_base_of_v<db::BaseTag, Tag>> {};
125 
126 /// \ingroup DataBoxGroup
127 /// \brief True if `Tag` is a DataBox tag.
128 template <typename Tag>
129 constexpr bool is_tag_v = is_tag<Tag>::value;
130 
131 /*!
132  * \ingroup DataBoxGroup
133  * \brief Check if `Tag` is a base DataBox tag.
134  *
135  * \see is_base_tag_v BaseTag
136  */
137 template <typename Tag>
139  : std::bool_constant<std::is_base_of_v<db::BaseTag, Tag> and
140  not std::is_base_of_v<db::SimpleTag, Tag>> {};
141 
142 /// \ingroup DataBoxGroup
143 /// \brief True if `Tag` is a base tag.
144 template <typename Tag>
146 
147 } // namespace db
std::bool_constant
db::is_tag
Check if Tag is a DataBox tag, i.e. a BaseTag, SimpleTag, ComputeTag, or ReferenceTag.
Definition: TagTraits.hpp:123
db::is_reference_tag_v
constexpr bool is_reference_tag_v
True if Tag derives from db::ReferenceTag.
Definition: TagTraits.hpp:44
db::is_reference_tag
Check if Tag derives off of db::ReferenceTag.
Definition: TagTraits.hpp:39
db::is_non_base_tag
Check if Tag is not a base tag.
Definition: TagTraits.hpp:108
db::is_base_tag_v
constexpr bool is_base_tag_v
True if Tag is a base tag.
Definition: TagTraits.hpp:145
db::is_compute_tag
Check if Tag derives off of db::ComputeTag.
Definition: TagTraits.hpp:25
db::is_compute_tag_v
constexpr bool is_compute_tag_v
True if Tag derives from db::ComputeTag.
Definition: TagTraits.hpp:30
db::is_mutable_item_tag
Check if Tag is a DataBox tag for a mutable item, i.e. a SimpleTag.
Definition: TagTraits.hpp:71
db::is_non_base_tag_v
constexpr bool is_non_base_tag_v
True if Tag is not a base tag.
Definition: TagTraits.hpp:113
db::is_simple_tag
Check if Tag is a simple tag.
Definition: TagTraits.hpp:91
db::is_tag_v
constexpr bool is_tag_v
True if Tag is a DataBox tag.
Definition: TagTraits.hpp:129
db::is_immutable_item_tag_v
constexpr bool is_immutable_item_tag_v
True if Tag is a DataBox tag for an immutable item, i.e. a ComputeTag or ReferenceTag.
Definition: TagTraits.hpp:62
db::is_immutable_item_tag
Check if Tag is a DataBox tag for an immutable item, i.e. a ComputeTag or ReferenceTag.
Definition: TagTraits.hpp:54
db::is_simple_tag_v
constexpr bool is_simple_tag_v
True if Tag is a simple tag.
Definition: TagTraits.hpp:99
type_traits
db::is_mutable_item_tag_v
constexpr bool is_mutable_item_tag_v
True if Tag is a DataBox tag for a mutable item, i.e. a SimpleTag.
Definition: TagTraits.hpp:79
db
Namespace for DataBox related things.
Definition: DataBox.hpp:44
std::is_base_of
db::is_base_tag
Check if Tag is a base DataBox tag.
Definition: TagTraits.hpp:138