A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../ranges/copyable_wrapper.html below:

Assignable wrapper (C++20) - cppreference.com

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.

The wrapper behaves exactly like std::optional<T>, except that the default constructor, copy assignment operator, and move assignment operator are (conditionally) different from those of std::optional, which augments T with assignability when needed and makes it always satisfy copyableor movable(since C++23).

[edit] Template parameters [edit] Member functions Default constructor

The default constructor is provided if and only if T models default_initializable.

A default-constructed wrapper contains a value-initialized T object.

Assignment operators (1)

constexpr /*copyable-box*/& operator=(const /*copyable-box*/& other);
    noexcept(/* see below */);

(since C++20)
(until C++23) constexpr /*movable-box*/& operator=(const /*movable-box*/& other);
    noexcept(/* see below */) requires std::copy_constructible<T>;
(since C++23) (2) (since C++20)
(until C++23) (since C++23) Members identical to std::optional Member functions constructs the optional object
(public member function of std::optional<T>) [edit] destroys the contained value, if there is one
(public member function of std::optional<T>) [edit] assigns contents
(public member function of std::optional<T>) [edit] Observers accesses the contained value
(public member function of std::optional<T>) [edit] checks whether the object contains a value
(public member function of std::optional<T>) [edit] Modifiers destroys any contained value
(public member function of std::optional<T>) [edit] constructs the contained value in-place
(public member function of std::optional<T>) [edit] [edit] 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).

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior P2325R3 C++20 if T is not default_initializable, the default constructor
constructs a wrapper which does not contain a value the wrapper is also
not default_initializable LWG 3572 C++20 conditionally different assignment operators were not constexpr made constexpr [edit] See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4