Files
cppdraft_translate/cppdraft/util/smartptr/weak/const.md
2025-10-25 03:02:53 +03:00

2.6 KiB

[util.smartptr.weak.const]

20 Memory management library [mem]

20.3 Smart pointers [smartptr]

20.3.2 Shared-ownership pointers [util.sharedptr]

20.3.2.3 Class template weak_ptr [util.smartptr.weak]

20.3.2.3.2 Constructors [util.smartptr.weak.const]

🔗

constexpr weak_ptr() noexcept;

1

#

Effects: Constructs an empty weak_ptr object that stores a null pointer value.

2

#

Postconditions: use_count() == 0.

🔗

constexpr weak_ptr(const weak_ptr& r) noexcept; template<class Y> constexpr weak_ptr(const weak_ptr<Y>& r) noexcept; template<class Y> constexpr weak_ptr(const shared_ptr<Y>& r) noexcept;

3

#

Constraints: For the second and third constructors, Y* is compatible with T*.

4

#

Effects: If r is empty, constructs an empty weak_ptr object that stores a null pointer value; otherwise, constructs a weak_ptr object that shares ownership with r and stores a copy of the pointer stored in r.

5

#

Postconditions: use_count() == r.use_count().

🔗

constexpr weak_ptr(weak_ptr&& r) noexcept; template<class Y> constexpr weak_ptr(weak_ptr<Y>&& r) noexcept;

6

#

Constraints: For the second constructor, Y* is compatible with T*.

7

#

Effects: Move constructs a weak_ptr instance from r.

8

#

Postconditions: *this contains the old value of r.

r is empty, stores a null pointer value, and r.use_count() == 0.