From Jason Turner

[range.move.wrap]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp23k0ckt2/{from.md → to.md} +49 -0
tmp/tmp23k0ckt2/{from.md → to.md} RENAMED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Movable wrapper <a id="range.move.wrap">[[range.move.wrap]]</a>
2
+
3
+ Many types in this subclause are specified in terms of an
4
+ exposition-only class template *`movable-box`*. `movable-box<T>` behaves
5
+ exactly like `optional<T>` with the following differences:
6
+
7
+ - `movable-box<T>` constrains its type parameter `T` with
8
+ `move_constructible<T> && is_object_v<T>`.
9
+ - The default constructor of `movable-box<T>` is equivalent to:
10
+ ``` cpp
11
+ constexpr movable-box() noexcept(is_nothrow_default_constructible_v<T>)
12
+ requires default_initializable<T>
13
+ : movable-box{in_place} {}
14
+ ```
15
+ - If `copyable<T>` is not modeled, the copy assignment operator is
16
+ equivalent to:
17
+ ``` cpp
18
+ constexpr movable-box& operator=(const movable-box& that)
19
+ noexcept(is_nothrow_copy_constructible_v<T>)
20
+ requires copy_constructible<T> {
21
+ if (this != addressof(that)) {
22
+ if (that) emplace(*that);
23
+ else reset();
24
+ }
25
+ return *this;
26
+ }
27
+ ```
28
+ - If `movable<T>` is not modeled, the move assignment operator is
29
+ equivalent to:
30
+ ``` cpp
31
+ constexpr movable-box& operator=(movable-box&& that)
32
+ noexcept(is_nothrow_move_constructible_v<T>) {
33
+ if (this != addressof(that)) {
34
+ if (that) emplace(std::move(*that));
35
+ else reset();
36
+ }
37
+ return *this;
38
+ }
39
+ ```
40
+
41
+ *Recommended practice:*
42
+
43
+ - If `copy_constructible<T>` is `true`, `movable-box<T>` should store
44
+ only a `T` if either `T` models `copyable`, or
45
+ `is_nothrow_move_constructible_v<T> && is_nothrow_copy_constructible_v<T>`
46
+ is `true`.
47
+ - Otherwise, `movable-box<T>` should store only a `T` if either `T`
48
+ models `movable` or `is_nothrow_move_constructible_v<T>` is `true`.
49
+