14 Jan
2018
14 Jan
'18
1:34 a.m.
Niall Douglas wrote:
How do you guarantee that only one instance of an error category will ever exist in the process?
If it's allowable to constexpr, I don't see how that's possible. I'd love to be corrected due to ignorance.
constexpr in this case doesn't change the number of instances that can exist in the process. The way to guarantee a single instance is to use the DLL/so runtime, and put the instance there.
MSVC's Immortalize is a directive to the VC runtime to ensure a single instance ever.
MS's _Immortalize is there to guarantee that the system_error machinery can be used during and after static destruction. That's why it's called "immortalize" - it makes the instance immortal, that is, makes sure its destructor is never invoked.