This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
[range.move.wrap]
# 25 Ranges library [[ranges]](./#ranges)
## 25.7 Range adaptors [[range.adaptors]](range.adaptors#range.move.wrap)
### 25.7.3 Movable wrapper [range.move.wrap]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L4308)
Many types in this subclause are specified in terms of
an exposition-only class template *movable-box*[.](#1.sentence-1)
*movable-box*<T> behaves exactly like optional<T> with the following differences:
- [(1.1)](#1.1)
*movable-box*<T> constrains
its type parameter T with[move_constructible](concept.moveconstructible#concept:move_constructible "18.4.13Concept move_­constructible[concept.moveconstructible]")<T> && is_object_v<T>.
- [(1.2)](#1.2)
The default
constructor of *movable-box*<T> is equivalent to:constexpr *movable-box*() noexcept(is_nothrow_default_constructible_v<T>)requires [default_initializable](concept.default.init#concept:default_initializable "18.4.12Concept default_­initializable[concept.default.init]")<T>: *movable-box*{in_place} {}
- [(1.3)](#1.3)
If [copyable](concepts.object#concept:copyable "18.6Object concepts[concepts.object]")<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](concept.copyconstructible#concept:copy_constructible "18.4.14Concept copy_­constructible[concept.copyconstructible]")<T> {if (this != addressof(that)) {if (that) emplace(*that); else reset(); }return *this;}
- [(1.4)](#1.4)
If [movable](concepts.object#concept:movable "18.6Object concepts[concepts.object]")<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;}
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L4354)
*Recommended practice*:
- [(2.1)](#2.1)
If [copy_constructible](concept.copyconstructible#concept:copy_constructible "18.4.14Concept copy_­constructible[concept.copyconstructible]")<T> is true,*movable-box*<T> should store only a T if either T models [copyable](concepts.object#concept:copyable "18.6Object concepts[concepts.object]"), oris_nothrow_move_constructible_v<T> && is_nothrow_copy_constructible_v<T> is true[.](#2.1.sentence-1)
- [(2.2)](#2.2)
Otherwise, *movable-box*<T> should store only a T if either T models [movable](concepts.object#concept:movable "18.6Object concepts[concepts.object]") oris_nothrow_move_constructible_v<T> is true[.](#2.2.sentence-1)