tmp/tmph0acd5_a/{from.md → to.md}
RENAMED
|
@@ -31,11 +31,11 @@ for dynamically allocated memory, passing ownership of dynamically
|
|
| 31 |
allocated memory to a function, and returning dynamically allocated
|
| 32 |
memory from a function. — *end note*]
|
| 33 |
|
| 34 |
#### Default deleters <a id="unique.ptr.dltr">[[unique.ptr.dltr]]</a>
|
| 35 |
|
| 36 |
-
#####
|
| 37 |
|
| 38 |
The class template `default_delete` serves as the default deleter
|
| 39 |
(destruction policy) for the class template `unique_ptr`.
|
| 40 |
|
| 41 |
The template parameter `T` of `default_delete` may be an incomplete
|
|
@@ -150,10 +150,16 @@ namespace std {
|
|
| 150 |
unique_ptr& operator=(const unique_ptr&) = delete;
|
| 151 |
};
|
| 152 |
}
|
| 153 |
```
|
| 154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
The default type for the template parameter `D` is `default_delete`. A
|
| 156 |
client-supplied template argument `D` shall be a function object type
|
| 157 |
[[function.objects]], lvalue reference to function, or lvalue reference
|
| 158 |
to function object type for which, given a value `d` of type `D` and a
|
| 159 |
value `ptr` of type `unique_ptr<T, D>::pointer`, the expression `d(ptr)`
|
|
@@ -378,11 +384,15 @@ constexpr unique_ptr& operator=(nullptr_t) noexcept;
|
|
| 378 |
|
| 379 |
``` cpp
|
| 380 |
constexpr add_lvalue_reference_t<T> operator*() const noexcept(noexcept(*declval<pointer>()));
|
| 381 |
```
|
| 382 |
|
| 383 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
|
| 385 |
*Returns:* `*get()`.
|
| 386 |
|
| 387 |
``` cpp
|
| 388 |
constexpr pointer operator->() const noexcept;
|
|
@@ -608,11 +618,11 @@ constexpr void reset(nullptr_t p = nullptr) noexcept;
|
|
| 608 |
```
|
| 609 |
|
| 610 |
*Effects:* Equivalent to `reset(pointer())`.
|
| 611 |
|
| 612 |
``` cpp
|
| 613 |
-
|
| 614 |
```
|
| 615 |
|
| 616 |
This function behaves the same as the `reset` member of the primary
|
| 617 |
template.
|
| 618 |
|
|
@@ -685,11 +695,11 @@ template<class T1, class D1, class T2, class D2>
|
|
| 685 |
|
| 686 |
*Returns:* `x.get() == y.get()`.
|
| 687 |
|
| 688 |
``` cpp
|
| 689 |
template<class T1, class D1, class T2, class D2>
|
| 690 |
-
bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 691 |
```
|
| 692 |
|
| 693 |
Let `CT` denote
|
| 694 |
|
| 695 |
``` cpp
|
|
@@ -708,34 +718,34 @@ ordering [[alg.sorting]] on the pointer values.
|
|
| 708 |
|
| 709 |
*Returns:* `less<CT>()(x.get(), y.get())`.
|
| 710 |
|
| 711 |
``` cpp
|
| 712 |
template<class T1, class D1, class T2, class D2>
|
| 713 |
-
bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 714 |
```
|
| 715 |
|
| 716 |
*Returns:* `y < x`.
|
| 717 |
|
| 718 |
``` cpp
|
| 719 |
template<class T1, class D1, class T2, class D2>
|
| 720 |
-
bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 721 |
```
|
| 722 |
|
| 723 |
*Returns:* `!(y < x)`.
|
| 724 |
|
| 725 |
``` cpp
|
| 726 |
template<class T1, class D1, class T2, class D2>
|
| 727 |
-
bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 728 |
```
|
| 729 |
|
| 730 |
*Returns:* `!(x < y)`.
|
| 731 |
|
| 732 |
``` cpp
|
| 733 |
template<class T1, class D1, class T2, class D2>
|
| 734 |
requires three_way_comparable_with<typename unique_ptr<T1, D1>::pointer,
|
| 735 |
typename unique_ptr<T2, D2>::pointer>
|
| 736 |
-
compare_three_way_result_t<typename unique_ptr<T1, D1>::pointer,
|
| 737 |
typename unique_ptr<T2, D2>::pointer>
|
| 738 |
operator<=>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 739 |
```
|
| 740 |
|
| 741 |
*Returns:* `compare_three_way()(x.get(), y.get())`.
|
|
|
|
| 31 |
allocated memory to a function, and returning dynamically allocated
|
| 32 |
memory from a function. — *end note*]
|
| 33 |
|
| 34 |
#### Default deleters <a id="unique.ptr.dltr">[[unique.ptr.dltr]]</a>
|
| 35 |
|
| 36 |
+
##### General <a id="unique.ptr.dltr.general">[[unique.ptr.dltr.general]]</a>
|
| 37 |
|
| 38 |
The class template `default_delete` serves as the default deleter
|
| 39 |
(destruction policy) for the class template `unique_ptr`.
|
| 40 |
|
| 41 |
The template parameter `T` of `default_delete` may be an incomplete
|
|
|
|
| 150 |
unique_ptr& operator=(const unique_ptr&) = delete;
|
| 151 |
};
|
| 152 |
}
|
| 153 |
```
|
| 154 |
|
| 155 |
+
A program that instantiates the definition of `unique_ptr<T, D>` is
|
| 156 |
+
ill-formed if `T*` is an invalid type.
|
| 157 |
+
|
| 158 |
+
[*Note 1*: This prevents the instantiation of specializations such as
|
| 159 |
+
`unique_ptr<T&, D>` and `unique_ptr<int() const, D>`. — *end note*]
|
| 160 |
+
|
| 161 |
The default type for the template parameter `D` is `default_delete`. A
|
| 162 |
client-supplied template argument `D` shall be a function object type
|
| 163 |
[[function.objects]], lvalue reference to function, or lvalue reference
|
| 164 |
to function object type for which, given a value `d` of type `D` and a
|
| 165 |
value `ptr` of type `unique_ptr<T, D>::pointer`, the expression `d(ptr)`
|
|
|
|
| 384 |
|
| 385 |
``` cpp
|
| 386 |
constexpr add_lvalue_reference_t<T> operator*() const noexcept(noexcept(*declval<pointer>()));
|
| 387 |
```
|
| 388 |
|
| 389 |
+
*Mandates:*
|
| 390 |
+
`reference_converts_from_temporary_v<add_lvalue_reference_t<T>, decltype(*declval<pointer>())>`
|
| 391 |
+
is `false`.
|
| 392 |
+
|
| 393 |
+
*Preconditions:* `get() != nullptr` is `true`.
|
| 394 |
|
| 395 |
*Returns:* `*get()`.
|
| 396 |
|
| 397 |
``` cpp
|
| 398 |
constexpr pointer operator->() const noexcept;
|
|
|
|
| 618 |
```
|
| 619 |
|
| 620 |
*Effects:* Equivalent to `reset(pointer())`.
|
| 621 |
|
| 622 |
``` cpp
|
| 623 |
+
template<class U> constexpr void reset(U p) noexcept;
|
| 624 |
```
|
| 625 |
|
| 626 |
This function behaves the same as the `reset` member of the primary
|
| 627 |
template.
|
| 628 |
|
|
|
|
| 695 |
|
| 696 |
*Returns:* `x.get() == y.get()`.
|
| 697 |
|
| 698 |
``` cpp
|
| 699 |
template<class T1, class D1, class T2, class D2>
|
| 700 |
+
constexpr bool operator<(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 701 |
```
|
| 702 |
|
| 703 |
Let `CT` denote
|
| 704 |
|
| 705 |
``` cpp
|
|
|
|
| 718 |
|
| 719 |
*Returns:* `less<CT>()(x.get(), y.get())`.
|
| 720 |
|
| 721 |
``` cpp
|
| 722 |
template<class T1, class D1, class T2, class D2>
|
| 723 |
+
constexpr bool operator>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 724 |
```
|
| 725 |
|
| 726 |
*Returns:* `y < x`.
|
| 727 |
|
| 728 |
``` cpp
|
| 729 |
template<class T1, class D1, class T2, class D2>
|
| 730 |
+
constexpr bool operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 731 |
```
|
| 732 |
|
| 733 |
*Returns:* `!(y < x)`.
|
| 734 |
|
| 735 |
``` cpp
|
| 736 |
template<class T1, class D1, class T2, class D2>
|
| 737 |
+
constexpr bool operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 738 |
```
|
| 739 |
|
| 740 |
*Returns:* `!(x < y)`.
|
| 741 |
|
| 742 |
``` cpp
|
| 743 |
template<class T1, class D1, class T2, class D2>
|
| 744 |
requires three_way_comparable_with<typename unique_ptr<T1, D1>::pointer,
|
| 745 |
typename unique_ptr<T2, D2>::pointer>
|
| 746 |
+
constexpr compare_three_way_result_t<typename unique_ptr<T1, D1>::pointer,
|
| 747 |
typename unique_ptr<T2, D2>::pointer>
|
| 748 |
operator<=>(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y);
|
| 749 |
```
|
| 750 |
|
| 751 |
*Returns:* `compare_three_way()(x.get(), y.get())`.
|