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

1.4 KiB

[util.smartptr.shared.dest]

20 Memory management library [mem]

20.3 Smart pointers [smartptr]

20.3.2 Shared-ownership pointers [util.sharedptr]

20.3.2.2 Class template shared_ptr [util.smartptr.shared]

20.3.2.2.3 Destructor [util.smartptr.shared.dest]

🔗

constexpr ~shared_ptr();

1

#

Effects:

  • (1.1)

    If *this is empty or shares ownership with anothershared_ptr instance (use_count() > 1), there are no side effects.

  • (1.2)

    Otherwise, if *this owns an objectp and a deleter d, d(p) is called.

  • (1.3)

    Otherwise, *this owns a pointer p, and delete p is called.

2

#

[Note 1:

Since the destruction of *this decreases the number of instances that share ownership with *this by one, after this has been destroyed all shared_ptr instances that shared ownership withthis will report a use_count() that is one less than its previous value.

— end note]