From Jason Turner

[unique.ptr]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpwwhtsxbz/{from.md → to.md} +44 -20
tmp/tmpwwhtsxbz/{from.md → to.md} RENAMED
@@ -48,10 +48,14 @@ namespace std {
48
  template<class T> struct default_delete<T[]>;
49
 
50
  template<class T, class D = default_delete<T>> class unique_ptr;
51
  template<class T, class D> class unique_ptr<T[], D>;
52
 
 
 
 
 
53
  template<class T, class D> void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
54
 
55
  template<class T1, class D1, class T2, class D2>
56
  bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
57
  template<class T1, class D1, class T2, class D2>
@@ -183,11 +187,11 @@ namespace std {
183
  unique_ptr& operator=(unique_ptr&& u) noexcept;
184
  template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
185
  unique_ptr& operator=(nullptr_t) noexcept;
186
 
187
  // [unique.ptr.single.observers], observers
188
- typename add_lvalue_reference<T>::type operator*() const;
189
  pointer operator->() const noexcept;
190
  pointer get() const noexcept;
191
  deleter_type& get_deleter() noexcept;
192
  const deleter_type& get_deleter() const noexcept;
193
  explicit operator bool() const noexcept;
@@ -213,16 +217,14 @@ is valid and has the effect of disposing of the pointer as appropriate
213
  for that deleter.
214
 
215
  If the deleter’s type `D` is not a reference type, `D` shall satisfy the
216
  requirements of `Destructible` (Table  [[destructible]]).
217
 
218
- If the type `remove_reference<D>::type::pointer` exists, then
219
- `unique_ptr<T,
220
- D>::pointer` shall be a synonym for
221
- `remove_reference<D>::type::pointer`. Otherwise
222
- `unique_ptr<T, D>::pointer` shall be a synonym for `T*`. The type
223
- `unique_ptr<T,
224
  D>::pointer` shall satisfy the requirements of `NullablePointer` (
225
  [[nullablepointer.requirements]]).
226
 
227
  Given an allocator type `X` ([[allocator.requirements]]) and letting
228
  `A` be a synonym for `allocator_traits<X>`, the types `A::pointer`,
@@ -418,18 +420,17 @@ unique_ptr& operator=(unique_ptr&& u) noexcept;
418
  ```
419
 
420
  *Requires:* If `D` is not a reference type, `D` shall satisfy the
421
  requirements of `MoveAssignable` (Table  [[moveassignable]]) and
422
  assignment of the deleter from an rvalue of type `D` shall not throw an
423
- exception. Otherwise, `D` is a reference type;
424
- `remove_reference<D>::type` shall satisfy the `CopyAssignable`
425
- requirements and assignment of the deleter from an lvalue of type `D`
426
- shall not throw an exception.
427
 
428
  *Effects:* Transfers ownership from `u` to `*this` as if by calling
429
- `reset(u.release())` followed by an assignment from
430
- `std::forward<D>(u.get_deleter())`.
431
 
432
  *Returns:* `*this`.
433
 
434
  ``` cpp
435
  template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
@@ -446,12 +447,12 @@ unless:
446
 
447
  - `unique_ptr<U, E>::pointer` is implicitly convertible to `pointer` and
448
  - `U` is not an array type.
449
 
450
  *Effects:* Transfers ownership from `u` to `*this` as if by calling
451
- `reset(u.release())` followed by an assignment from
452
- `std::forward<D>(u.get_deleter())`.
453
 
454
  *Returns:* `*this`.
455
 
456
  ``` cpp
457
  unique_ptr& operator=(nullptr_t) noexcept;
@@ -464,11 +465,11 @@ unique_ptr& operator=(nullptr_t) noexcept;
464
  *Returns:* `*this`.
465
 
466
  ##### `unique_ptr` observers <a id="unique.ptr.single.observers">[[unique.ptr.single.observers]]</a>
467
 
468
  ``` cpp
469
- typename add_lvalue_reference<T>::type operator*() const;
470
  ```
471
 
472
  *Requires:* `get() != nullptr`.
473
 
474
  *Returns:* `*get()`.
@@ -627,18 +628,41 @@ stored pointer points.
627
  *Returns:* `get()[i]`.
628
 
629
  ##### `unique_ptr` modifiers <a id="unique.ptr.runtime.modifiers">[[unique.ptr.runtime.modifiers]]</a>
630
 
631
  ``` cpp
632
- void reset(pointer p = pointer()) noexcept;
633
  void reset(nullptr_t p) noexcept;
634
  ```
635
 
636
- *Effects:* If `get() == nullptr` there are no effects. Otherwise
637
- `get_deleter()(get())`.
638
 
639
- `get() == p`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
640
 
641
  #### `unique_ptr` specialized algorithms <a id="unique.ptr.special">[[unique.ptr.special]]</a>
642
 
643
  ``` cpp
644
  template <class T, class D> void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
 
48
  template<class T> struct default_delete<T[]>;
49
 
50
  template<class T, class D = default_delete<T>> class unique_ptr;
51
  template<class T, class D> class unique_ptr<T[], D>;
52
 
53
+ template<class T, class... Args> unique_ptr<T> make_unique(Args&&... args);
54
+ template<class T> unique_ptr<T> make_unique(size_t n);
55
+ template<class T, class... Args> unspecified make_unique(Args&&...) = delete;
56
+
57
  template<class T, class D> void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;
58
 
59
  template<class T1, class D1, class T2, class D2>
60
  bool operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
61
  template<class T1, class D1, class T2, class D2>
 
187
  unique_ptr& operator=(unique_ptr&& u) noexcept;
188
  template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
189
  unique_ptr& operator=(nullptr_t) noexcept;
190
 
191
  // [unique.ptr.single.observers], observers
192
+ add_lvalue_reference_t<T> operator*() const;
193
  pointer operator->() const noexcept;
194
  pointer get() const noexcept;
195
  deleter_type& get_deleter() noexcept;
196
  const deleter_type& get_deleter() const noexcept;
197
  explicit operator bool() const noexcept;
 
217
  for that deleter.
218
 
219
  If the deleter’s type `D` is not a reference type, `D` shall satisfy the
220
  requirements of `Destructible` (Table  [[destructible]]).
221
 
222
+ If the type `remove_reference_t<D>::pointer` exists, then `unique_ptr<T,
223
+ D>::pointer` shall be a synonym for `remove_reference_t<D>::pointer`.
224
+ Otherwise `unique_ptr<T, D>::pointer` shall be a synonym for `T*`. The
225
+ type `unique_ptr<T,
 
 
226
  D>::pointer` shall satisfy the requirements of `NullablePointer` (
227
  [[nullablepointer.requirements]]).
228
 
229
  Given an allocator type `X` ([[allocator.requirements]]) and letting
230
  `A` be a synonym for `allocator_traits<X>`, the types `A::pointer`,
 
420
  ```
421
 
422
  *Requires:* If `D` is not a reference type, `D` shall satisfy the
423
  requirements of `MoveAssignable` (Table  [[moveassignable]]) and
424
  assignment of the deleter from an rvalue of type `D` shall not throw an
425
+ exception. Otherwise, `D` is a reference type; `remove_reference_t<D>`
426
+ shall satisfy the `CopyAssignable` requirements and assignment of the
427
+ deleter from an lvalue of type `D` shall not throw an exception.
 
428
 
429
  *Effects:* Transfers ownership from `u` to `*this` as if by calling
430
+ `reset(u.release())` followed by
431
+ `get_deleter() = std::forward<D>(u.get_deleter())`.
432
 
433
  *Returns:* `*this`.
434
 
435
  ``` cpp
436
  template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
 
447
 
448
  - `unique_ptr<U, E>::pointer` is implicitly convertible to `pointer` and
449
  - `U` is not an array type.
450
 
451
  *Effects:* Transfers ownership from `u` to `*this` as if by calling
452
+ `reset(u.release())` followed by
453
+ `get_deleter() = std::forward<E>(u.get_deleter())`.
454
 
455
  *Returns:* `*this`.
456
 
457
  ``` cpp
458
  unique_ptr& operator=(nullptr_t) noexcept;
 
465
  *Returns:* `*this`.
466
 
467
  ##### `unique_ptr` observers <a id="unique.ptr.single.observers">[[unique.ptr.single.observers]]</a>
468
 
469
  ``` cpp
470
+ add_lvalue_reference_t<T> operator*() const;
471
  ```
472
 
473
  *Requires:* `get() != nullptr`.
474
 
475
  *Returns:* `*get()`.
 
628
  *Returns:* `get()[i]`.
629
 
630
  ##### `unique_ptr` modifiers <a id="unique.ptr.runtime.modifiers">[[unique.ptr.runtime.modifiers]]</a>
631
 
632
  ``` cpp
 
633
  void reset(nullptr_t p) noexcept;
634
  ```
635
 
636
+ *Effects:* Equivalent to `reset(pointer())`.
 
637
 
638
+ #### `unique_ptr` creation <a id="unique.ptr.create">[[unique.ptr.create]]</a>
639
+
640
+ ``` cpp
641
+ template <class T, class... Args> unique_ptr<T> make_unique(Args&&... args);
642
+ ```
643
+
644
+ *Remarks:* This function shall not participate in overload resolution
645
+ unless `T` is not an array.
646
+
647
+ *Returns:* `unique_ptr<T>(new T(std::forward<Args>(args)...))`.
648
+
649
+ ``` cpp
650
+ template <class T> unique_ptr<T> make_unique(size_t n);
651
+ ```
652
+
653
+ *Remarks:* This function shall not participate in overload resolution
654
+ unless `T` is an array of unknown bound.
655
+
656
+ *Returns:* `unique_ptr<T>(new remove_extent_t<T>[n]())`.
657
+
658
+ ``` cpp
659
+ template <class T, class... Args> unspecified make_unique(Args&&...) = delete;
660
+ ```
661
+
662
+ *Remarks:* This function shall not participate in overload resolution
663
+ unless `T` is an array of known bound.
664
 
665
  #### `unique_ptr` specialized algorithms <a id="unique.ptr.special">[[unique.ptr.special]]</a>
666
 
667
  ``` cpp
668
  template <class T, class D> void swap(unique_ptr<T, D>& x, unique_ptr<T, D>& y) noexcept;