15#ifndef RANGES_V3_UTILITY_BOX_HPP
16#define RANGES_V3_UTILITY_BOX_HPP
30#include <range/v3/detail/prologue.hpp>
33RANGES_DIAGNOSTIC_IGNORE_DEPRECATED_DECLARATIONS
43 struct RANGES_DEPRECATED(
"The ranges::mutable_ class template is deprecated") mutable_
48 constexpr CPP_ctor(mutable_)()(
49 requires std::is_default_constructible<T>::value)
52 constexpr explicit mutable_(T
const & t)
55 constexpr explicit mutable_(T && t)
56 : value(detail::move(t))
58 mutable_
const & operator=(T
const & t)
const
63 mutable_
const & operator=(T && t)
const
65 value = detail::move(t);
68 constexpr operator T &()
const &
74 template<
typename T, T v>
75 struct RANGES_DEPRECATED(
"The ranges::constant class template is deprecated") constant
78 constexpr explicit constant(T
const &)
80 constant & operator=(T
const &)
84 constant
const & operator=(T
const &)
const
88 constexpr operator T()
const
92 constexpr T exchange(T
const &)
const
103 enum class box_compress
116 template<
typename Fn>
118 !std::is_copy_assignable<Fn>::value>;
121 constexpr box_compress box_compression_(...)
123 return box_compress::none;
128#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 6 && __GNUC_MINOR__ < 2
137 constexpr box_compress box_compression_(
long)
139 return box_compress::ebo;
141#ifndef RANGES_WORKAROUND_MSVC_249830
147 constexpr box_compress box_compression_(
int)
149 return box_compress::coalesce;
153 constexpr box_compress box_compression()
155 return box_compression_<T>(0);
160 template<
typename Element,
typename Tag = void,
161 detail::box_compress = detail::box_compression<Element>()>
168 constexpr CPP_ctor(
box)()(
169 noexcept(std::is_nothrow_default_constructible<Element>::value)
170 requires std::is_default_constructible<Element>::value)
173#if defined(__cpp_conditional_explicit) && __cpp_conditional_explicit > 0
174 template(
typename E)(
175 requires (!same_as<
box, detail::decay_t<E>>) AND
176 constructible_from<Element, E>)
177 constexpr explicit(!convertible_to<E, Element>)
box(E && e)
178 noexcept(std::is_nothrow_constructible<Element, E>::value)
179 : value(
static_cast<E &&
>(e))
182 template(
typename E)(
183 requires (!same_as<
box, detail::decay_t<E>>) AND
184 constructible_from<Element, E> AND
185 convertible_to<E, Element>)
186 constexpr box(E && e)
187 noexcept(std::is_nothrow_constructible<Element, E>::value)
188 : value(
static_cast<E &&
>(e))
190 template(
typename E)(
191 requires (!same_as<
box, detail::decay_t<E>>) AND
192 constructible_from<Element, E> AND
193 (!convertible_to<E, Element>))
194 constexpr explicit box(E && e)
195 noexcept(std::is_nothrow_constructible<Element, E>::value)
196 : value(
static_cast<E &&
>(e))
200 constexpr Element & get() &
noexcept
204 constexpr Element
const & get()
const &
noexcept
208 constexpr Element && get() &&
noexcept
210 return detail::move(value);
212 constexpr Element
const && get()
const &&
noexcept
214 return detail::move(value);
218 template<
typename Element,
typename Tag>
223 constexpr CPP_ctor(
box)()(
224 noexcept(std::is_nothrow_default_constructible<Element>::value)
225 requires std::is_default_constructible<Element>::value)
228#if defined(__cpp_conditional_explicit) && __cpp_conditional_explicit > 0
229 template(
typename E)(
230 requires (!same_as<
box, detail::decay_t<E>>) AND
231 constructible_from<Element, E>)
232 constexpr explicit(!convertible_to<E, Element>)
box(E && e)
233 noexcept(std::is_nothrow_constructible<Element, E>::value)
234 : Element(
static_cast<E &&
>(e))
237 template(
typename E)(
238 requires (!same_as<
box, detail::decay_t<E>>) AND
239 constructible_from<Element, E> AND
240 convertible_to<E, Element>)
241 constexpr box(E && e)
242 noexcept(std::is_nothrow_constructible<Element, E>::value)
243 : Element(
static_cast<E &&
>(e))
245 template(
typename E)(
246 requires (!same_as<
box, detail::decay_t<E>>) AND
247 constructible_from<Element, E> AND
248 (!convertible_to<E, Element>))
249 constexpr explicit box(E && e)
250 noexcept(std::is_nothrow_constructible<Element, E>::value)
251 : Element(
static_cast<E &&
>(e))
255 constexpr Element & get() &
noexcept
259 constexpr Element
const & get()
const &
noexcept
263 constexpr Element && get() &&
noexcept
265 return detail::move(*
this);
267 constexpr Element
const && get()
const &&
noexcept
269 return detail::move(*
this);
273 template<
typename Element,
typename Tag>
276 static Element value;
279 constexpr box()
noexcept =
default;
281#if defined(__cpp_conditional_explicit) && __cpp_conditional_explicit > 0
282 template(
typename E)(
283 requires (!same_as<
box, detail::decay_t<E>>) AND
284 constructible_from<Element, E>)
285 constexpr explicit(!convertible_to<E, Element>)
box(E &&)
noexcept
288 template(
typename E)(
289 requires (!same_as<
box, detail::decay_t<E>>) AND
290 constructible_from<Element, E> AND
291 convertible_to<E, Element>)
292 constexpr box(E &&)
noexcept
294 template(
typename E)(
295 requires (!same_as<
box, detail::decay_t<E>>) AND
296 constructible_from<Element, E> AND
297 (!convertible_to<E, Element>))
298 constexpr explicit box(E &&)
noexcept
302 constexpr Element & get() &
noexcept
306 constexpr Element
const & get()
const &
noexcept
310 constexpr Element && get() &&
noexcept
312 return detail::move(value);
314 constexpr Element
const && get()
const &&
noexcept
316 return detail::move(value);
320 template<
typename Element,
typename Tag>
328 template<
typename Tag,
typename Element, detail::box_compress BC>
329 constexpr Element & get(box<Element, Tag, BC> & b)
noexcept
333 template<
typename Tag,
typename Element, detail::box_compress BC>
334 constexpr Element
const & get(box<Element, Tag, BC>
const & b)
noexcept
338 template<
typename Tag,
typename Element, detail::box_compress BC>
339 constexpr Element && get(box<Element, Tag, BC> && b)
noexcept
341 return detail::move(b).get();
344 template<std::
size_t I,
typename Element, detail::box_compress BC>
345 constexpr Element & get(box<Element,
meta::size_t<I>, BC> & b)
noexcept
349 template<std::
size_t I,
typename Element, detail::box_compress BC>
350 constexpr Element
const & get(
355 template<std::
size_t I,
typename Element, detail::box_compress BC>
356 constexpr Element && get(box<Element,
meta::size_t<I>, BC> && b)
noexcept
358 return detail::move(b).get();
368#include <range/v3/detail/epilogue.hpp>
std::integral_constant< bool, B > bool_
An integral constant wrapper for bool.
Definition meta.hpp:168
std::integral_constant< std::size_t, N > size_t
An integral constant wrapper for std::size_t.
Definition meta.hpp:163
_t< detail::_if_< list< Args... > > > if_
Select one type or another depending on a compile-time Boolean.
Definition meta.hpp:1247
not_c< B::type::value > not_
Logically negate the integral constant-wrapped Boolean parameter.
Definition meta.hpp:1357