From Jason Turner

[unique.ptr.single.ctor]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp357y7tie/{from.md → to.md} +65 -85
tmp/tmp357y7tie/{from.md → to.md} RENAMED
@@ -1,97 +1,78 @@
1
- ##### `unique_ptr` constructors <a id="unique.ptr.single.ctor">[[unique.ptr.single.ctor]]</a>
2
 
3
  ``` cpp
4
  constexpr unique_ptr() noexcept;
5
  constexpr unique_ptr(nullptr_t) noexcept;
6
  ```
7
 
8
- *Requires:* `D` shall satisfy the requirements of `DefaultConstructible`
9
- (Table  [[tab:defaultconstructible]]), and that construction shall not
10
- throw an exception.
 
 
 
11
 
12
  *Effects:* Constructs a `unique_ptr` object that owns nothing,
13
  value-initializing the stored pointer and the stored deleter.
14
 
15
- *Postconditions:* `get() == nullptr`. `get_deleter()` returns a
16
- reference to the stored deleter.
17
-
18
- *Remarks:* If `is_pointer_v<deleter_type>` is `true` or
19
- `is_default_constructible_v<deleter_type>` is `false`, this constructor
20
- shall not participate in overload resolution.
21
 
22
  ``` cpp
23
  explicit unique_ptr(pointer p) noexcept;
24
  ```
25
 
26
- *Requires:* `D` shall satisfy the requirements of `DefaultConstructible`
27
- (Table  [[tab:defaultconstructible]]), and that construction shall not
28
- throw an exception.
 
 
 
 
 
 
29
 
30
  *Effects:* Constructs a `unique_ptr` which owns `p`, initializing the
31
  stored pointer with `p` and value-initializing the stored deleter.
32
 
33
- *Postconditions:* `get() == p`. `get_deleter()` returns a reference to
34
- the stored deleter.
35
-
36
- *Remarks:* If `is_pointer_v<deleter_type>` is `true` or
37
- `is_default_constructible_v<deleter_type>` is `false`, this constructor
38
- shall not participate in overload resolution. If class template argument
39
- deduction ([[over.match.class.deduct]]) would select the function
40
- template corresponding to this constructor, then the program is
41
- ill-formed.
42
-
43
- ``` cpp
44
- unique_ptr(pointer p, see below d1) noexcept;
45
- unique_ptr(pointer p, see below d2) noexcept;
46
- ```
47
-
48
- The signature of these constructors depends upon whether `D` is a
49
- reference type. If `D` is a non-reference type `A`, then the signatures
50
- are:
51
 
52
  ``` cpp
53
- unique_ptr(pointer p, const A& d) noexcept;
54
- unique_ptr(pointer p, A&& d) noexcept;
55
  ```
56
 
57
- If `D` is an lvalue reference type `A&`, then the signatures are:
58
 
59
- ``` cpp
60
- unique_ptr(pointer p, A& d) noexcept;
61
- unique_ptr(pointer p, A&& d) = delete;
62
- ```
63
-
64
- If `D` is an lvalue reference type `const A&`, then the signatures are:
65
 
66
- ``` cpp
67
- unique_ptr(pointer p, const A& d) noexcept;
68
- unique_ptr(pointer p, const A&& d) = delete;
69
- ```
 
70
 
71
  *Effects:* Constructs a `unique_ptr` object which owns `p`, initializing
72
  the stored pointer with `p` and initializing the deleter from
73
  `std::forward<decltype(d)>(d)`.
74
 
75
- *Remarks:* These constructors shall not participate in overload
76
- resolution unless `is_constructible_v<D, decltype(d)>` is `true`.
 
77
 
78
- *Postconditions:* `get() == p`. `get_deleter()` returns a reference to
79
- the stored deleter. If `D` is a reference type then `get_deleter()`
80
- returns a reference to the lvalue `d`.
81
-
82
- *Remarks:* If class template argument
83
- deduction ([[over.match.class.deduct]]) would select a function
84
- template corresponding to either of these constructors, then the program
85
- is ill-formed.
86
 
87
  [*Example 1*:
88
 
89
  ``` cpp
90
  D d;
91
- unique_ptr<int, D> p1(new int, D()); // D must be MoveConstructible
92
- unique_ptr<int, D> p2(new int, d); // D must be CopyConstructible
93
  unique_ptr<int, D&> p3(new int, d); // p3 holds a reference to d
94
  unique_ptr<int, const D&> p4(new int, D()); // error: rvalue deleter object combined
95
  // with reference deleter type
96
  ```
97
 
@@ -99,54 +80,53 @@ unique_ptr<int, const D&> p4(new int, D()); // error: rvalue deleter object comb
99
 
100
  ``` cpp
101
  unique_ptr(unique_ptr&& u) noexcept;
102
  ```
103
 
104
- *Requires:* If `D` is not a reference type, `D` shall satisfy the
105
- requirements of `MoveConstructible` (Table  [[tab:moveconstructible]]).
106
- Construction of the deleter from an rvalue of type `D` shall not throw
107
- an exception.
108
 
109
- *Effects:* Constructs a `unique_ptr` by transferring ownership from `u`
110
- to `*this`. If `D` is a reference type, this deleter is copy constructed
111
- from `u`’s deleter; otherwise, this deleter is move constructed from
112
- `u`’s deleter.
113
 
114
- [*Note 1*: The deleter constructor can be implemented with
 
 
 
 
115
  `std::forward<D>`. — *end note*]
116
 
117
- *Postconditions:* `get()` yields the value `u.get()` yielded before the
118
- construction. `get_deleter()` returns a reference to the stored deleter
119
- that was constructed from `u.get_deleter()`. If `D` is a reference type
120
- then `get_deleter()` and `u.get_deleter()` both reference the same
121
- lvalue deleter.
122
 
123
  ``` cpp
124
  template<class U, class E> unique_ptr(unique_ptr<U, E>&& u) noexcept;
125
  ```
126
 
127
- *Requires:* If `E` is not a reference type, construction of the deleter
128
- from an rvalue of type `E` shall be well formed and shall not throw an
129
- exception. Otherwise, `E` is a reference type and construction of the
130
- deleter from an lvalue of type `E` shall be well formed and shall not
131
- throw an exception.
132
-
133
- *Remarks:* This constructor shall not participate in overload resolution
134
- unless:
135
 
136
  - `unique_ptr<U, E>::pointer` is implicitly convertible to `pointer`,
137
  - `U` is not an array type, and
138
  - either `D` is a reference type and `E` is the same type as `D`, or `D`
139
  is not a reference type and `E` is implicitly convertible to `D`.
140
 
141
- *Effects:* Constructs a `unique_ptr` by transferring ownership from `u`
142
- to `*this`. If `E` is a reference type, this deleter is copy constructed
143
- from `u`’s deleter; otherwise, this deleter is move constructed from
144
- `u`’s deleter.
 
 
 
 
 
145
 
146
  [*Note 2*: The deleter constructor can be implemented with
147
  `std::forward<E>`. — *end note*]
148
 
149
- *Postconditions:* `get()` yields the value `u.get()` yielded before the
150
- construction. `get_deleter()` returns a reference to the stored deleter
151
- that was constructed from `u.get_deleter()`.
152
 
 
1
+ ##### Constructors <a id="unique.ptr.single.ctor">[[unique.ptr.single.ctor]]</a>
2
 
3
  ``` cpp
4
  constexpr unique_ptr() noexcept;
5
  constexpr unique_ptr(nullptr_t) noexcept;
6
  ```
7
 
8
+ *Preconditions:* `D` meets the *Cpp17DefaultConstructible* requirements
9
+ ([[cpp17.defaultconstructible]]), and that construction does not throw
10
+ an exception.
11
+
12
+ *Constraints:* `is_pointer_v<deleter_type>` is `false` and
13
+ `is_default_constructible_v<deleter_type>` is `true`.
14
 
15
  *Effects:* Constructs a `unique_ptr` object that owns nothing,
16
  value-initializing the stored pointer and the stored deleter.
17
 
18
+ *Ensures:* `get() == nullptr`. `get_deleter()` returns a reference to
19
+ the stored deleter.
 
 
 
 
20
 
21
  ``` cpp
22
  explicit unique_ptr(pointer p) noexcept;
23
  ```
24
 
25
+ *Constraints:* `is_pointer_v<deleter_type>` is `false` and
26
+ `is_default_constructible_v<deleter_type>` is `true`.
27
+
28
+ *Mandates:* This constructor is not selected by class template argument
29
+ deduction [[over.match.class.deduct]].
30
+
31
+ *Preconditions:* `D` meets the *Cpp17DefaultConstructible* requirements
32
+ ([[cpp17.defaultconstructible]]), and that construction does not throw
33
+ an exception.
34
 
35
  *Effects:* Constructs a `unique_ptr` which owns `p`, initializing the
36
  stored pointer with `p` and value-initializing the stored deleter.
37
 
38
+ *Ensures:* `get() == p`. `get_deleter()` returns a reference to the
39
+ stored deleter.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  ``` cpp
42
+ unique_ptr(pointer p, const D& d) noexcept;
43
+ unique_ptr(pointer p, remove_reference_t<D>&& d) noexcept;
44
  ```
45
 
46
+ *Constraints:* `is_constructible_v<D, decltype(d)>` is `true`.
47
 
48
+ *Mandates:* These constructors are not selected by class template
49
+ argument deduction [[over.match.class.deduct]].
 
 
 
 
50
 
51
+ *Preconditions:* For the first constructor, if `D` is not a reference
52
+ type, `D` meets the *Cpp17CopyConstructible* requirements and such
53
+ construction does not exit via an exception. For the second constructor,
54
+ if `D` is not a reference type, `D` meets the *Cpp17MoveConstructible*
55
+ requirements and such construction does not exit via an exception.
56
 
57
  *Effects:* Constructs a `unique_ptr` object which owns `p`, initializing
58
  the stored pointer with `p` and initializing the deleter from
59
  `std::forward<decltype(d)>(d)`.
60
 
61
+ *Ensures:* `get() == p`. `get_deleter()` returns a reference to the
62
+ stored deleter. If `D` is a reference type then `get_deleter()` returns
63
+ a reference to the lvalue `d`.
64
 
65
+ *Remarks:* If `D` is a reference type, the second constructor is defined
66
+ as deleted.
 
 
 
 
 
 
67
 
68
  [*Example 1*:
69
 
70
  ``` cpp
71
  D d;
72
+ unique_ptr<int, D> p1(new int, D()); // D must be Cpp17MoveConstructible
73
+ unique_ptr<int, D> p2(new int, d); // D must be Cpp17CopyConstructible
74
  unique_ptr<int, D&> p3(new int, d); // p3 holds a reference to d
75
  unique_ptr<int, const D&> p4(new int, D()); // error: rvalue deleter object combined
76
  // with reference deleter type
77
  ```
78
 
 
80
 
81
  ``` cpp
82
  unique_ptr(unique_ptr&& u) noexcept;
83
  ```
84
 
85
+ *Constraints:* `is_move_constructible_v<D>` is `true`.
 
 
 
86
 
87
+ *Preconditions:* If `D` is not a reference type, `D` meets the
88
+ *Cpp17MoveConstructible* requirements ([[cpp17.moveconstructible]]).
89
+ Construction of the deleter from an rvalue of type `D` does not throw an
90
+ exception.
91
 
92
+ *Effects:* Constructs a `unique_ptr` from `u`. If `D` is a reference
93
+ type, this deleter is copy constructed from `u`’s deleter; otherwise,
94
+ this deleter is move constructed from `u`’s deleter.
95
+
96
+ [*Note 1*: The construction of the deleter can be implemented with
97
  `std::forward<D>`. — *end note*]
98
 
99
+ *Ensures:* `get()` yields the value `u.get()` yielded before the
100
+ construction. `u.get() == nullptr`. `get_deleter()` returns a reference
101
+ to the stored deleter that was constructed from `u.get_deleter()`. If
102
+ `D` is a reference type then `get_deleter()` and `u.get_deleter()` both
103
+ reference the same lvalue deleter.
104
 
105
  ``` cpp
106
  template<class U, class E> unique_ptr(unique_ptr<U, E>&& u) noexcept;
107
  ```
108
 
109
+ *Constraints:*
 
 
 
 
 
 
 
110
 
111
  - `unique_ptr<U, E>::pointer` is implicitly convertible to `pointer`,
112
  - `U` is not an array type, and
113
  - either `D` is a reference type and `E` is the same type as `D`, or `D`
114
  is not a reference type and `E` is implicitly convertible to `D`.
115
 
116
+ *Preconditions:* If `E` is not a reference type, construction of the
117
+ deleter from an rvalue of type `E` is well-formed and does not throw an
118
+ exception. Otherwise, `E` is a reference type and construction of the
119
+ deleter from an lvalue of type `E` is well-formed and does not throw an
120
+ exception.
121
+
122
+ *Effects:* Constructs a `unique_ptr` from `u`. If `E` is a reference
123
+ type, this deleter is copy constructed from `u`’s deleter; otherwise,
124
+ this deleter is move constructed from `u`’s deleter.
125
 
126
  [*Note 2*: The deleter constructor can be implemented with
127
  `std::forward<E>`. — *end note*]
128
 
129
+ *Ensures:* `get()` yields the value `u.get()` yielded before the
130
+ construction. `u.get() == nullptr`. `get_deleter()` returns a reference
131
+ to the stored deleter that was constructed from `u.get_deleter()`.
132