Assignable wrapper (C++20)

ranges::single_view, ranges::repeat_view,(since C++23) and range adaptors that store an invocable object are specified in terms of an exposition-only class template copyable-box(until C++23)movable-box(since C++23). The name shown here is for exposition purposes only.

# Declarations

template< class T >
requires std::copy_constructible<T> && std::is_object_v<T>
class /*copyable-box*/;

(since C++20) (until C++23) (exposition only*)

template< class T >
requires std::move_constructible<T> && std::is_object_v<T>
class /*movable-box*/;

(since C++23) (exposition only*)

# Notes

A copyable-box(until C++23)movable-box(since C++23) does not contain a value only if

Before P2325R3, the wrapper was called semiregular-box in the standard and always satisfied semiregular, as the default constructor was always provided (which might construct a valueless wrapper).

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
P2325R3C++20if T is not default_initializable, the default constructorconstructs a wrapper which does not contain a valuethe wrapper is alsonot default_initializable
LWG 3572C++20conditionally different assignment operators were not constexprmade constexpr

# See also