std::experi...nges::tagged(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

okay so welcome to the std::experi...nges::tagged(3) page from the C++ Standard Library, bestie 🫢 β€” we're talking about std::experimental::ranges::tagged, and it's literally the std::experimental::ranges::tagged class template. That's the name, that's the vibe, no cap ✨.

✨ Synopsis ✨

Defined in header <experimental/ranges/utility>
template< class Base, TagSpecifier... Tags >

    requires sizeof...(Tags) <= std::tuple_size<Base>::value  (ranges TS)

struct tagged;

The class template tagged augments a tuple-like class type Base, which it publicly derives from, with a set of named accessors specified by the tag specifiers Tags.... The tags are applied in order: the i-th tag specifier in Tags... correspond to the i-th element of the tuple. πŸ’…

bestie, the tag specifiers in Tags... shall be unique. Otherwise, the behavior is undefined 😭 β€” so no duplicate tags, fr fr.
also important: it is not possible to delete an instance of tagged through a pointer to any base other than Base. periodt πŸ’€

πŸ’… Member functions πŸ’…

  • constructor β€” construct a tagged object (public member function)
  • operator= β€” assigns a tagged object (public member function)
  • swap β€” swaps the contents of two tagged objects (public member function)

πŸŽ€ Named element accessors πŸŽ€

For the N-th tag specifier in Tags... whose corresponding element name is name, tagged provides accessors named name as follows:

constexpr decltype(auto) name() &       { return std::get<N>(*this); }
constexpr decltype(auto) name() const & { return std::get<N>(*this); }
constexpr decltype(auto) name() &&      { return std::get<N>(std::move(*this)); }

🌈 Non-member functions 🌈

  • ranges::swap(ranges::tagged) β€” specializes swap for tagged objects (function)

✨ Tuple-like access ✨

  • std::tuple_size<std::experimental::ranges::tagged> β€” obtains the size of a tagged (class template specialization)
  • std::tuple_element<std::experimental::ranges::tagged> β€” obtains the types of the elements of a tagged (class template specialization)

πŸ¦‹ See also πŸ¦‹

  • TagSpecifier β€” specifies that a type is a tag specifier (concept)
  • tagged_pair β€” alias template for a tagged std::pair (alias template)
  • make_tagged_pair β€” convenience function for creating a tagged_pair (function template)
  • tagged_tuple β€” alias template for a tagged std::tuple (alias template)
  • make_tagged_tuple β€” convenience function for creating a tagged_tuple (function template)
  • in, in1, in2, out, out1, out2, fun, min, max, begin, end β€” tag specifiers for use with ranges::tagged (class)

okay that's the whole page, bestie πŸ’– source: http://cppreference.com, version: 2024.06.10, date: 2024.06.10 β€” mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from