Skip to main navigation Skip to search Skip to main content

constexpr std::shared_ptr and friends

    Research output: Other contributionpeer-review

    2 Downloads (Pure)

    Abstract

    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.
    Original languageEnglish
    TypeProgramming Language Standard
    Media of outputPrint
    PublisherInternational Organization for Standardization (ISO)
    Number of pages39
    Place of PublicationGeneva
    Publication statusPublished - 30 Jun 2025

    UN SDGs

    This output contributes to the following UN Sustainable Development Goals (SDGs)

    1. SDG 8 - Decent Work and Economic Growth
      SDG 8 Decent Work and Economic Growth
    2. SDG 9 - Industry, Innovation, and Infrastructure
      SDG 9 Industry, Innovation, and Infrastructure
    3. SDG 11 - Sustainable Cities and Communities
      SDG 11 Sustainable Cities and Communities

    Keywords

    • C++
    • constexpr
    • smart pointers
    • C++26

    Fingerprint

    Dive into the research topics of 'constexpr std::shared_ptr and friends'. Together they form a unique fingerprint.

    Cite this