Skip to content

Commit 08ca953

Browse files
author
Colin Robertson
committed
Correct more declarations.
1 parent 68d5ca4 commit 08ca953

1 file changed

Lines changed: 71 additions & 22 deletions

File tree

‎docs/standard-library/memory-functions.md‎

Lines changed: 71 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ Gets the true address of an object.
1414
```cpp
1515
template <class T>
1616
T* addressof(
17-
T& value);
17+
T& value) noexcept; // before C++17
18+
19+
template <class T>
20+
constexpr T* addressof(
21+
T& value) noexcept; // C++17
22+
23+
template <class T>
24+
const T* addressof(
25+
const T&& value) = delete; // C++17
1826
```
1927
2028
### Parameters
@@ -225,7 +233,11 @@ Const cast to [shared_ptr](shared-ptr-class.md).
225233
```cpp
226234
template <class Type, class Other>
227235
shared_ptr<Type> const_pointer_cast(
228-
const shared_ptr<Other>& sp);
236+
const shared_ptr<Other>& sp) noexcept;
237+
238+
template <class Type, class Other>
239+
shared_ptr<Type> const_pointer_cast(
240+
shared_ptr<Other>&& sp) noexcept;
229241
```
230242
231243
### Parameters
@@ -386,7 +398,11 @@ Dynamic cast to [shared_ptr](shared-ptr-class.md).
386398
```cpp
387399
template <class Type, class Other>
388400
shared_ptr<Type> dynamic_pointer_cast(
389-
const shared_ptr<Other>& sp);
401+
const shared_ptr<Other>& sp) noexcept;
402+
403+
template <class Type, class Other>
404+
shared_ptr<Type> dynamic_pointer_cast(
405+
shared_ptr<Other>&& sp) noexcept;
390406
```
391407
392408
### Parameters
@@ -447,7 +463,7 @@ Get the deleter from a [shared_ptr](shared-ptr-class.md).
447463
```cpp
448464
template <class D, class Type>
449465
D* get_deleter(
450-
const shared_ptr<Type>& sp);
466+
const shared_ptr<Type>& sp) noexcept;
451467
```
452468
453469
### Parameters
@@ -514,7 +530,7 @@ get_deleter(sp1) != 0 == true
514530
Returns the type of pointer safety assumed by any garbage collector.
515531

516532
```cpp
517-
pointer_safety get_pointer_safety();
533+
pointer_safety get_pointer_safety() noexcept;
518534
```
519535

520536
### Remarks
@@ -744,30 +760,53 @@ struct owner_less< shared_ptr<Type> >
744760
{
745761
bool operator()(
746762
const shared_ptr<Type>& left,
747-
const shared_ptr<Type>& right);
763+
const shared_ptr<Type>& right) const noexcept;
748764
749765
bool operator()(
750766
const shared_ptr<Type>& left,
751-
const weak_ptr<Type>& right);
767+
const weak_ptr<Type>& right) const noexcept;
752768
753769
bool operator()(
754770
const weak_ptr<Type>& left,
755-
const shared_ptr<Type>& right);
771+
const shared_ptr<Type>& right) const noexcept;
756772
};
757773
758774
template <class Type>
759775
struct owner_less<weak_ptr<Type>>
760776
bool operator()(
761777
const weak_ptr<Type>& left,
762-
const weak_ptr<Type>& right);
778+
const weak_ptr<Type>& right) const noexcept;
763779
764780
bool operator()(
765781
const weak_ptr<Type>& left,
766-
const shared_ptr<Type>& right);
782+
const shared_ptr<Type>& right) const noexcept;
767783
768784
bool operator()(
769785
const shared_ptr<Type>& left,
770-
const weak_ptr<Type>& right);
786+
const weak_ptr<Type>& right) const noexcept;
787+
};
788+
789+
template<> struct owner_less<void>
790+
{
791+
template<class T, class U>
792+
bool operator()(
793+
const shared_ptr<T>& left,
794+
const shared_ptr<U>& right) const noexcept;
795+
796+
template<class T, class U>
797+
bool operator()(
798+
const shared_ptr<T>& left,
799+
const weak_ptr<U>& right) const noexcept;
800+
801+
template<class T, class U>
802+
bool operator()(
803+
const weak_ptr<T>& left,
804+
const shared_ptr<U>& right) const noexcept;
805+
806+
template<class T, class U>
807+
bool operator()(
808+
const weak_ptr<T>& left,
809+
const weak_ptr<U>& right) const noexcept;
771810
};
772811
```
773812

@@ -872,7 +911,11 @@ Static cast to [shared_ptr](shared-ptr-class.md).
872911
```cpp
873912
template <class Type, class Other>
874913
shared_ptr<Type> static_pointer_cast(
875-
const shared_ptr<Other>& sp);
914+
const shared_ptr<Other>& sp) noexcept;
915+
916+
template <class Type, class Other>
917+
shared_ptr<Type> static_pointer_cast(
918+
shared_ptr<Other>&& sp) noexcept;
876919
```
877920
878921
### Parameters
@@ -927,33 +970,39 @@ sp1->value == 3
927970

928971
## <a name="swap"></a> swap
929972

930-
Swap two [shared_ptr](shared-ptr-class.md) or [weak_ptr](weak-ptr-class.md) objects.
973+
Swap two [shared_ptr](shared-ptr-class.md), [unique_ptr](unique-ptr-class.md), or [weak_ptr](weak-ptr-class.md) objects.
931974

932975
```cpp
933-
template <class Type, class Other>
976+
template <class Type>
934977
void swap(
935978
shared_ptr<Type>& left,
936-
shared_ptr<Other>& right);
979+
shared_ptr<Type>& right) noexcept;
937980

938-
template <class Type, class Other>
981+
template <class Type, class D>
982+
void swap(
983+
unique_ptr<Type, D>& left,
984+
unique_ptr<Type, D>& right) noexcept;
985+
986+
template <class Type>
939987
void swap(
940988
weak_ptr<Type>& left,
941-
weak_ptr<Other>& right);
989+
weak_ptr<Type>& right) noexcept;
990+
942991
```
943992
944993
### Parameters
945994
946995
*Type*\
947-
The type controlled by the left shared/weak pointer.
996+
The type controlled by the argument pointer.
948997
949-
*Other*\
950-
The type controlled by the right shared/weak pointer.
998+
*D*\
999+
The deleter of the unique pointer type.
9511000
9521001
*left*\
953-
The left shared/weak pointer.
1002+
The left pointer.
9541003
9551004
*right*\
956-
The right shared/weak pointer.
1005+
The right pointer.
9571006
9581007
### Remarks
9591008

0 commit comments

Comments
 (0)