|
SpECTRE
v2025.08.19
|
TaggedVariant and related functionality. More...
Classes | |
| class | TaggedVariant |
A class similar to std::variant, but indexed by tag structs. More... | |
Functions | |
| template<typename Tag , typename... Tags> | |
| constexpr bool | holds_alternative (const TaggedVariant< Tags... > &variant) |
Check whether Tag is active. | |
| template<typename... Tags> | |
| constexpr bool | operator== (const TaggedVariant< Tags... > &a, const TaggedVariant< Tags... > &b) |
| template<typename... Tags> | |
| constexpr bool | operator!= (const TaggedVariant< Tags... > &a, const TaggedVariant< Tags... > &b) |
| template<typename... Tags> | |
| constexpr bool | operator< (const TaggedVariant< Tags... > &a, const TaggedVariant< Tags... > &b) |
| template<typename... Tags> | |
| constexpr bool | operator> (const TaggedVariant< Tags... > &a, const TaggedVariant< Tags... > &b) |
| template<typename... Tags> | |
| constexpr bool | operator<= (const TaggedVariant< Tags... > &a, const TaggedVariant< Tags... > &b) |
| template<typename... Tags> | |
| constexpr bool | operator>= (const TaggedVariant< Tags... > &a, const TaggedVariant< Tags... > &b) |
| template<typename... Tags, Requires<(... and(std::is_move_constructible_v< typename Tags::type > and std::is_swappable_v< typename Tags::type >))> = nullptr> | |
| constexpr void | swap (TaggedVariant< Tags... > &a, TaggedVariant< Tags... > &b) noexcept(noexcept(a.swap(b))) |
| template<typename Visitor , typename... Variants, Requires<(... and TaggedVariant_detail::is_variant_or_derived(std::add_pointer_t< std::remove_reference_t< Variants > >{}))> = nullptr> | |
| constexpr decltype(auto) | visit (Visitor &&visitor, Variants &&... variants) |
Call visitor with the contents of one or more variants. More... | |
| template<typename R , typename Visitor , typename... Variants, Requires<(... and TaggedVariant_detail::is_variant_or_derived(std::add_pointer_t< std::remove_reference_t< Variants > >{}))> = nullptr> | |
| constexpr R | visit (Visitor &&visitor, Variants &&... variants) |
Call visitor with the contents of one or more variants. More... | |
| template<typename Tag , typename... Tags> | |
| constexpr Tag::type & | get (TaggedVariant< Tags... > &variant) |
Access the contained object. Throws std::bad_variant_access if Tag is not active. | |
| template<typename Tag , typename... Tags> | |
| constexpr const Tag::type & | get (const TaggedVariant< Tags... > &variant) |
Access the contained object. Throws std::bad_variant_access if Tag is not active. | |
| template<typename Tag , typename... Tags> | |
| constexpr Tag::type && | get (TaggedVariant< Tags... > &&variant) |
Access the contained object. Throws std::bad_variant_access if Tag is not active. | |
| template<typename Tag , typename... Tags> | |
| constexpr const Tag::type && | get (const TaggedVariant< Tags... > &&variant) |
Access the contained object. Throws std::bad_variant_access if Tag is not active. | |
| template<typename Tag , typename... Tags> | |
| constexpr const Tag::type * | get_if (const TaggedVariant< Tags... > *variant) |
Returns a pointer to the contained object if variant is a non-null pointer and Tag is active. Otherwise, returns nullptr. | |
| template<typename Tag , typename... Tags> | |
| constexpr Tag::type * | get_if (TaggedVariant< Tags... > *variant) |
Returns a pointer to the contained object if variant is a non-null pointer and Tag is active. Otherwise, returns nullptr. | |
| template<typename... Tags, typename Tag , Requires<(sizeof...(Tags) > 1 and(... or std::is_same_v< Tags, Tag >))> = nullptr> | |
| constexpr bool | operator== (const TaggedVariant< Tags... > &a, const TaggedVariant< Tag > &b) |
| Comparison operators against single-tag variants. Primarily useful in tests. | |
| template<typename... Tags, typename Tag , Requires<(sizeof...(Tags) > 1 and(... or std::is_same_v< Tags, Tag >))> = nullptr> | |
| constexpr bool | operator== (const TaggedVariant< Tag > &a, const TaggedVariant< Tags... > &b) |
| Comparison operators against single-tag variants. Primarily useful in tests. | |
| template<typename... Tags, typename Tag , Requires<(sizeof...(Tags) > 1 and(... or std::is_same_v< Tags, Tag >))> = nullptr> | |
| constexpr bool | operator!= (const TaggedVariant< Tags... > &a, const TaggedVariant< Tag > &b) |
| Comparison operators against single-tag variants. Primarily useful in tests. | |
| template<typename... Tags, typename Tag , Requires<(sizeof...(Tags) > 1 and(... or std::is_same_v< Tags, Tag >))> = nullptr> | |
| constexpr bool | operator!= (const TaggedVariant< Tag > &a, const TaggedVariant< Tags... > &b) |
| Comparison operators against single-tag variants. Primarily useful in tests. | |
TaggedVariant and related functionality.
|
constexpr |
Call visitor with the contents of one or more variants.
Calls visitor with the contents of each variant as arguments, passed as std::pair<tmpl::type_<Tag>, typename Tag::type ref>, where Tag is the active tag of the variant and ref is a reference qualifier matching that of the passed variant.
If the template parameter R is supplied, the result is implicitly converted to that type (which may be void). Otherwise it is deduced from the return type of visitor, which must be the same for all tags in the variant.
visit for std::variant, the types of the visitor arguments do not allow for implicit conversions between reference types. If the visitor expects, for example, std::pair<tmpl::type_<Tag>, const typename Tag::type&>, the caller must ensure that the passed variant is a const lvalue.
|
constexpr |
Call visitor with the contents of one or more variants.
Calls visitor with the contents of each variant as arguments, passed as std::pair<tmpl::type_<Tag>, typename Tag::type ref>, where Tag is the active tag of the variant and ref is a reference qualifier matching that of the passed variant.
If the template parameter R is supplied, the result is implicitly converted to that type (which may be void). Otherwise it is deduced from the return type of visitor, which must be the same for all tags in the variant.
visit for std::variant, the types of the visitor arguments do not allow for implicit conversions between reference types. If the visitor expects, for example, std::pair<tmpl::type_<Tag>, const typename Tag::type&>, the caller must ensure that the passed variant is a const lvalue.