On Friday, October 24, 2025, Frederick Virchanza Gotham wrote:
You could get this on a microcontroller too, where addresses above 0x2000 are volatile memory, and addresses from 0x0 to 0x800 are the input into 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;
};
}
And actually, a class could provide its own implementation of 'replace', something like:
namespace std {
class mutex {
public:
void _Replace(void)
{
. . .
}
};
}
and then the Standard library 'replace' function could be written something like:
template<typename T, typename... Params>
void replace(T *const p, Params&&... args)
{
if constexpr ( requires { p->_Replace(); } )
{
p->_Replace( forward<Params>(args)... );
}
else
{
. . .
}
}
But also we might need to talk about replacing an object with an object of a different type, such as when working with std::variant.