Line data Source code
1 0 : // 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 ComputeTag; 12 : struct ReferenceTag; 13 : } // namespace db 14 : namespace Parallel::Tags { 15 : struct Metavariables; 16 : } // namespace Parallel::Tags 17 : /// \endcond 18 : 19 : namespace db { 20 : /*! 21 : * \ingroup DataBoxGroup 22 : * \brief Check if `Tag` derives off of db::ComputeTag. 23 : * 24 : * \see is_compute_tag_v ComputeTag 25 : */ 26 : template <typename Tag> 27 1 : struct is_compute_tag : std::is_base_of<db::ComputeTag, Tag> {}; 28 : 29 : /// \ingroup DataBoxGroup 30 : /// \brief True if `Tag` derives from db::ComputeTag. 31 : template <typename Tag> 32 1 : constexpr bool is_compute_tag_v = is_compute_tag<Tag>::value; 33 : 34 : /*! 35 : * \ingroup DataBoxGroup 36 : * \brief Check if `Tag` derives off of db::ReferenceTag. 37 : * 38 : * \see is_reference_tag_v ReferenceTag 39 : */ 40 : template <typename Tag> 41 1 : struct is_reference_tag : std::is_base_of<db::ReferenceTag, Tag> {}; 42 : 43 : /// \ingroup DataBoxGroup 44 : /// \brief True if `Tag` derives from db::ReferenceTag. 45 : template <typename Tag> 46 1 : constexpr bool is_reference_tag_v = is_reference_tag<Tag>::value; 47 : 48 : /*! 49 : * \ingroup DataBoxGroup 50 : * \brief Check if `Tag` is a DataBox tag for an immutable item, i.e. a 51 : * ComputeTag or ReferenceTag 52 : * 53 : * \see is_immutable_item_tag_v 54 : */ 55 : template <typename Tag> 56 1 : struct is_immutable_item_tag 57 : : std::bool_constant<std::is_base_of_v<db::ReferenceTag, Tag> or 58 : std::is_base_of_v<db::ComputeTag, Tag>> {}; 59 : 60 : /// \ingroup DataBoxGroup 61 : /// \brief True if `Tag` is a DataBox tag for an immutable item, i.e. a 62 : /// ComputeTag or ReferenceTag. 63 : template <typename Tag> 64 1 : constexpr bool is_immutable_item_tag_v = is_immutable_item_tag<Tag>::value; 65 : 66 : /*! 67 : * \ingroup DataBoxGroup 68 : * \brief Check if `Tag` is a DataBox tag for a mutable item, i.e. a SimpleTag 69 : * 70 : * \see is_mutable_item_tag_v 71 : */ 72 : template <typename Tag> 73 1 : struct is_mutable_item_tag 74 : : std::bool_constant<std::is_base_of_v<db::SimpleTag, Tag> and 75 : not is_compute_tag_v<Tag> and 76 : not is_reference_tag_v<Tag>> {}; 77 : 78 : /// \ingroup DataBoxGroup 79 : /// \brief True if `Tag` is a DataBox tag for a mutable item, i.e. a SimpleTag 80 : template <typename Tag> 81 1 : constexpr bool is_mutable_item_tag_v = is_mutable_item_tag<Tag>::value; 82 : 83 : /*! 84 : * \ingroup DataBoxGroup 85 : * \brief Check if `Tag` is a simple tag. 86 : * 87 : * \details This is done by deriving from std::true_type if `Tag` is derived 88 : * from db::SimpleTag, but not from db::ComputeTag or db::ReferenceTag. 89 : * 90 : * \see is_simple_tag_v SimpleTag 91 : */ 92 : template <typename Tag> 93 1 : struct is_simple_tag 94 : : std::bool_constant<std::is_base_of_v<db::SimpleTag, Tag> and 95 : not is_compute_tag_v<Tag> and 96 : not is_reference_tag_v<Tag>> {}; 97 : 98 : /// \ingroup DataBoxGroup 99 : /// \brief True if `Tag` is a simple tag. 100 : template <typename Tag> 101 1 : constexpr bool is_simple_tag_v = is_simple_tag<Tag>::value; 102 : 103 : /*! 104 : * \ingroup DataBoxGroup 105 : * \brief Check if `Tag` is a simple, compute, or reference tag. 106 : * 107 : * \see is_non_base_tag_v BaseTag 108 : */ 109 : template <typename Tag> 110 1 : struct is_creation_tag : std::is_base_of<db::SimpleTag, Tag> {}; 111 : 112 : /// \ingroup DataBoxGroup 113 : /// \brief True if `Tag` is not a base tag. 114 : template <typename Tag> 115 1 : constexpr bool is_creation_tag_v = is_creation_tag<Tag>::value; 116 : 117 : /*! 118 : * \ingroup DataBoxGroup 119 : * \brief Check if `Tag` is a DataBox tag, i.e. a SimpleTag, ComputeTag, 120 : * ReferenceTag, or the special tag Parallel::Tags::Metavariables. 121 : * 122 : * \see is_tag_v 123 : */ 124 : template <typename Tag> 125 1 : struct is_tag 126 : : std::bool_constant<std::is_base_of_v<db::SimpleTag, Tag> or 127 : std::is_same_v<Tag, Parallel::Tags::Metavariables>> {}; 128 : 129 : /// \ingroup DataBoxGroup 130 : /// \brief True if `Tag` is a DataBox tag. 131 : template <typename Tag> 132 1 : constexpr bool is_tag_v = is_tag<Tag>::value; 133 : } // namespace db