14#ifndef RANGES_V3_UTILITY_TAGGED_PAIR_HPP
15#define RANGES_V3_UTILITY_TAGGED_PAIR_HPP
25#include <range/v3/detail/adl_get.hpp>
28#include <range/v3/detail/prologue.hpp>
31RANGES_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
44 template<
typename Base, std::size_t,
typename...>
47 using type = _tuple_wrapper_::forward_tuple_interface<Base>;
49 template<
typename Base, std::size_t I,
typename First,
typename... Rest>
50 struct tagged_chain<Base, I, First, Rest...>
52 using type =
typename First::template getter<
53 Base, I,
meta::_t<tagged_chain<Base, I + 1, Rest...>>>;
57#if RANGES_BROKEN_CPO_LOOKUP
66 template<
typename Base,
typename... Tags>
67 class RANGES_EMPTY_BASES RANGES_DEPRECATED(
68 "Class template tagged is deprecated.") tagged
69 :
public meta::_t<detail::tagged_chain<Base, 0, Tags...>>
70#if RANGES_BROKEN_CPO_LOOKUP
71 ,
private _tagged_::adl_hook_
74 CPP_assert(same_as<Base, uncvref_t<Base>>);
75 using base_t =
meta::_t<detail::tagged_chain<Base, 0, Tags...>>;
77 template<
typename Other>
80 detail::is_convertible<Other, Base>::value>
86 template(
typename Other)(
87 requires can_convert<Other>::value)
88 constexpr tagged(tagged<Other, Tags...> && that)
89 noexcept(std::is_nothrow_constructible<Base, Other>::value)
90 : base_t(static_cast<Other &&>(that))
92 template(
typename Other)(
93 requires can_convert<Other>::value)
94 constexpr tagged(tagged<Other, Tags...>
const & that)
95 noexcept(std::is_nothrow_constructible<Base, Other const &>::value)
96 : base_t(static_cast<Other const &>(that))
98 template(
typename Other)(
99 requires can_convert<Other>::value)
100 constexpr tagged & operator=(tagged<Other, Tags...> && that)
102 noexcept(std::declval<Base &>() =
static_cast<Other &&
>(that)))
104 static_cast<Base &
>(*this) =
static_cast<Other &&
>(that);
107 template(
typename Other)(
108 requires can_convert<Other>::value)
109 constexpr tagged & operator=(tagged<Other, Tags...>
const & that)
111 noexcept(std::declval<Base &>() =
static_cast<Other
const &
>(that)))
113 static_cast<Base &
>(*this) =
static_cast<Other
const &
>(that);
116 template(
typename U)(
117 requires (!same_as<tagged, detail::decay_t<U>>) AND
118 satisfies<Base &, std::is_assignable, U>)
119 constexpr tagged &
operator=(U && u)
120 noexcept(
noexcept(std::declval<Base &>() =
static_cast<U &&
>(u)))
122 static_cast<Base &
>(*this) =
static_cast<U &&
>(u);
125 template(
typename B = Base)(
126 requires is_swappable<B>::value)
127 constexpr void swap(tagged & that)
noexcept(is_nothrow_swappable<B>::value)
129 ranges::swap(
static_cast<Base &
>(*
this),
static_cast<Base &
>(that));
131#if !RANGES_BROKEN_CPO_LOOKUP
132 template<
typename B = Base>
133 friend constexpr auto swap(tagged & x, tagged & y)
134 noexcept(is_nothrow_swappable<B>::value)
135 -> CPP_broken_friend_ret(
void)(
136 requires is_swappable<B>::value)
143#if RANGES_BROKEN_CPO_LOOKUP
146 template(
typename Base,
typename... Tags)(
147 requires is_swappable<Base>::value)
148 constexpr void swap(tagged<Base, Tags...> & x, tagged<Base, Tags...> & y)
149 noexcept(is_nothrow_swappable<Base>::value)
156 template<
typename F,
typename S>
157 using tagged_pair RANGES_DEPRECATED(
"ranges::tagged_pair is deprecated.") =
158 tagged<std::pair<detail::tag_elem<F>, detail::tag_elem<S>>, detail::tag_spec<F>,
159 detail::tag_spec<S>>;
161 template<
typename Tag1,
typename Tag2,
typename T1,
typename T2,
162 typename R = tagged_pair<Tag1(bind_element_t<T1>), Tag2(bind_element_t<T2>)>>
163 RANGES_DEPRECATED(
"ranges::make_tagged_pair is deprecated.")
164 constexpr R make_tagged_pair(T1 && t1, T2 && t2) noexcept(
165 std::is_nothrow_constructible<R, T1, T2>::value)
167 return {
static_cast<T1 &&
>(t1),
static_cast<T2 &&
>(t2)};
171#define RANGES_DEFINE_TAG_SPECIFIER(NAME) \
176 template<typename Untagged, std::size_t I, typename Next> \
177 class getter : public Next \
180 ~getter() = default; \
183 getter() = default; \
184 getter(getter &&) = default; \
185 getter(getter const &) = default; \
187 getter & operator=(getter &&) = default; \
188 getter & operator=(getter const &) = default; \
189 constexpr meta::_t<std::tuple_element<I, Untagged>> & NAME() & \
190 noexcept(noexcept(detail::adl_get<I>(std::declval<Untagged &>()))) \
192 return detail::adl_get<I>(static_cast<Untagged &>(*this)); \
194 constexpr meta::_t<std::tuple_element<I, Untagged>> && NAME() && \
195 noexcept(noexcept(detail::adl_get<I>(std::declval<Untagged>()))) \
197 return detail::adl_get<I>(static_cast<Untagged &&>(*this)); \
199 constexpr meta::_t<std::tuple_element<I, Untagged>> const & NAME() \
201 noexcept(detail::adl_get<I>(std::declval<Untagged const &>()))) \
203 return detail::adl_get<I>(static_cast<Untagged const &>(*this)); \
210RANGES_DIAGNOSTIC_IGNORE_MISMATCHED_TAGS
214 template<
typename Untagged,
typename... Tags>
215 struct tuple_size<::ranges::tagged<Untagged, Tags...>> : tuple_size<Untagged>
218 template<
size_t N,
typename Untagged,
typename... Tags>
219 struct tuple_element<N, ::ranges::tagged<Untagged, Tags...>>
220 : tuple_element<N, Untagged>
226#include <range/v3/detail/epilogue.hpp>
std::integral_constant< bool, B > bool_
An integral constant wrapper for bool.
Definition meta.hpp:168
typename T::type _t
Type alias for T::type.
Definition meta.hpp:141
_t< detail::back_< L > > back
Return the last element in meta::list L.
Definition meta.hpp:2103
_t< detail::front_< L > > front
Return the first element in meta::list L.
Definition meta.hpp:2070