C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Replace an object -- but retain old object if new object fails to construct

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Fri, 24 Oct 2025 11:50:03 +0000
On Friday, October 24, 2025, Sebastian Wittmeier wrote:

> You don't know the reason the object is unmovable.
>
> The address space of the object may be mapped to the hardware.
>
> Copying and restoring may lead to errors.
>
>
>
> Simple example: A DMA buffer.
>


You could get this on a microcontroller too, where addresses above 0x2000
are volatile memory, and addresses from 0x0 to 0x800 are the input for a
digital-to-analog converter.

And so if the 'replace' template function were to be added to the C++
Standard library, then some classes would need to be given a tag to
indicate that you can't put them into temporary cryostasis, something like:

namespace std {
    class mutex {
    public:
        typedef int no_cryostasis;
    };
}

Received on 2025-10-24 11:50:06