[range.move.wrap] (original) (raw)
25 Ranges library [ranges]
25.7 Range adaptors [range.adaptors]
25.7.3 Movable wrapper [range.move.wrap]
Many types in this subclause are specified in terms of an exposition-only class template movable-box.
movable-box<T> behaves exactly like optional<T>with the following differences:
- movable-box<T> constrains its type parameter T withmove_constructible<T> && is_object_v<T>.
- The default constructor of movable-box<T> is equivalent to:constexpr movable-box() noexcept(is_nothrow_default_constructible_v<T>) requires default_initializable<T> : movable-box{in_place} {}
- If copyable<T> is not modeled, the copy assignment operator is equivalent to:constexpr movable-box& operator=(const movable-box& that) noexcept(is_nothrow_copy_constructible_v<T>) requires copy_constructible<T> { if (this != addressof(that)) { if (that) emplace(*that);else reset();} return *this;}
- If movable<T> is not modeled, the move assignment operator is equivalent to:constexpr movable-box& operator=(movable-box&& that) noexcept(is_nothrow_move_constructible_v<T>) { if (this != addressof(that)) { if (that) emplace(std::move(*that));else reset();} return *this;}
Recommended practice:
- If copy_constructible<T> is true,movable-box<T> should store only a Tif either T models copyable, oris_nothrow_move_constructible_v<T> && is_nothrow_copy_constructible_v<T>is true.
- Otherwise, movable-box<T> should store only a Tif either T models movable oris_nothrow_move_constructible_v<T> is true.