8 General utilities library [utilities]

8.5 Tagged tuple-like types [taggedtup]

8.5.4 Alias template tagged_pair [tagged.pairs]

// defined in header <experimental/ranges/utility>

namespace std { namespace experimental { namespace ranges { inline namespace v1 {
  // ...
  template <TaggedType T1, TaggedType T2>
  using tagged_pair = tagged<pair<TAGELEM(T1), TAGELEM(T2)>,
                             TAGSPEC(T1), TAGSPEC(T2)>;
}}}}

Example:

// See [alg.tagspec]:
tagged_pair<tag::min(int), tag::max(int)> p{0, 1};
assert(&p.min() == &p.first);
assert(&p.max() == &p.second);

 — end example ]

8.5.4.1 Tagged pair creation functions [tagged.pairs.creation]

// defined in header <experimental/ranges/utility> namespace std { namespace experimental { namespace ranges { inline namespace v1 { template <TagSpecifier Tag1, TagSpecifier Tag2, class T1, class T2> constexpr see below make_tagged_pair(T1&& x, T2&& y); }}}}

Let P be the type of make_pair(std::forward<T1>(x), std::forward<T2>(y)). Then the return type is tagged<P, Tag1, Tag2>.

Returns: {std::forward<T1>(x), std::forward<T2>(y)}.

Example: In place of:

  return tagged_pair<tag::min(int), tag::max(double)>(5, 3.1415926);   // explicit types

a C++ program may contain:

  return make_tagged_pair<tag::min, tag::max>(5, 3.1415926);           // types are deduced

 — end example ]