TagTraits.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <type_traits>
8 
9 #include "Utilities/Requires.hpp"
10 #include "Utilities/TypeTraits.hpp"
11 
12 /// \cond
13 namespace db {
14 struct SimpleTag;
15 struct BaseTag;
16 struct ComputeTag;
17 } // namespace db
18 /// \endcond
19 
20 namespace db {
21 /*!
22  * \ingroup DataBoxGroup
23  * \brief Check if `Tag` derives off of db::ComputeTag.
24  *
25  * \see is_compute_tag_v ComputeTag
26  */
27 template <typename Tag>
28 struct is_compute_tag : std::is_base_of<db::ComputeTag, Tag> {};
29 
30 /// \ingroup DataBoxGroup
31 /// \brief True if `Tag` derives from db::ComputeTag.
32 template <typename Tag>
34 
35 /*!
36  * \ingroup DataBoxGroup
37  * \brief Check if `Tag` is a simple tag.
38  *
39  * \details This is done by deriving from std::true_type if `Tag` is derived
40  * from db::SimpleTag, but not from db::ComputeTag.
41  *
42  * \see is_simple_tag_v SimpleTag
43  */
44 template <typename Tag>
46  : std::bool_constant<std::is_base_of_v<db::SimpleTag, Tag> and
47  not is_compute_tag_v<Tag>> {};
48 
49 /// \ingroup DataBoxGroup
50 /// \brief True if `Tag` is a simple tag.
51 template <typename Tag>
53 
54 /*!
55  * \ingroup DataBoxGroup
56  * \brief Check if `Tag` is not a base tag.
57  *
58  * \see is_non_base_tag_v BaseTag
59  */
60 template <typename Tag>
62  : std::bool_constant<std::is_base_of_v<db::ComputeTag, Tag> or
63  std::is_base_of_v<db::SimpleTag, Tag>> {};
64 
65 /// \ingroup DataBoxGroup
66 /// \brief True if `Tag` is not a base tag.
67 template <typename Tag>
69 
70 /*!
71  * \ingroup DataBoxGroup
72  * \brief Check if `Tag` is a DataBox tag, i.e. a BaseTag, SimpleTag, or
73  * ComputeTag
74  *
75  * \see is_tag_v
76  */
77 template <typename Tag>
78 struct is_tag : std::bool_constant<std::is_base_of_v<db::ComputeTag, Tag> or
79  std::is_base_of_v<db::SimpleTag, Tag> or
80  std::is_base_of_v<db::BaseTag, Tag>> {};
81 
82 /// \ingroup DataBoxGroup
83 /// \brief True if `Tag` is a DataBox tag.
84 template <typename Tag>
85 constexpr bool is_tag_v = is_tag<Tag>::value;
86 
87 /*!
88  * \ingroup DataBoxGroup
89  * \brief Check if `Tag` is a base DataBox tag.
90  *
91  * \see is_base_tag_v BaseTag
92  */
93 template <typename Tag>
95  : std::bool_constant<std::is_base_of_v<db::BaseTag, Tag> and
96  not std::is_base_of_v<db::SimpleTag, Tag> and
97  not is_compute_tag_v<Tag>> {};
98 
99 /// \ingroup DataBoxGroup
100 /// \brief True if `Tag` is a base tag.
101 template <typename Tag>
103 
104 } // namespace db
std::bool_constant
db::is_tag
Check if Tag is a DataBox tag, i.e. a BaseTag, SimpleTag, or ComputeTag.
Definition: TagTraits.hpp:78
db::is_non_base_tag
Check if Tag is not a base tag.
Definition: TagTraits.hpp:61
db::is_base_tag_v
constexpr bool is_base_tag_v
True if Tag is a base tag.
Definition: TagTraits.hpp:102
db::is_compute_tag
Check if Tag derives off of db::ComputeTag.
Definition: TagTraits.hpp:28
db::is_compute_tag_v
constexpr bool is_compute_tag_v
True if Tag derives from db::ComputeTag.
Definition: TagTraits.hpp:33
db::is_non_base_tag_v
constexpr bool is_non_base_tag_v
True if Tag is not a base tag.
Definition: TagTraits.hpp:68
cstddef
db::is_simple_tag
Check if Tag is a simple tag.
Definition: TagTraits.hpp:45
db::is_tag_v
constexpr bool is_tag_v
True if Tag is a DataBox tag.
Definition: TagTraits.hpp:85
Requires.hpp
db::is_simple_tag_v
constexpr bool is_simple_tag_v
True if Tag is a simple tag.
Definition: TagTraits.hpp:52
type_traits
db
Namespace for DataBox related things.
Definition: DataBox.hpp:43
std::is_base_of
db::is_base_tag
Check if Tag is a base DataBox tag.
Definition: TagTraits.hpp:94