constexpr std::shared_ptr and friends
Since the adoption of [P0784R7] in C++20, constant expressions can include dynamic memory allocation; yet support for smart pointers extends only to std::unique_ptr (since [P2273R3] in C++23). As at runtime, smart pointers can encourage hygienic memory management during constant evaluation; and with no remaining technical obstacles, parity between runtime and compile-time support for smart pointers should reflect the increased maturity of language support for constant expression evaluation. We therefore propose that std::shared_ptr and appropriate classes and template member functions from [smartptr], as well as smart pointer specialisations of std::atomic from [util.smartptr.atomic] permit constexpr evaluation.
Authors
- Paul; id_orcid 0000-0002-4781-9377 Keir
- Hana Dusíková
Publication Details
- Journal
- The UWS Academic Portal (University of the West of Scotland)
- Published
- 2025-06-30
- Primary Topic
- Logic, programming, and type systems
- Type
- article
- Field-Weighted Citation Impact
- 0.00