13 Jan
2018
13 Jan
'18
12:15 a.m.
Andrey Semashev wrote:
3, Make the default constructor constexpr, now possible. No code should notice a difference, except less runtime code will be generated.
Not sure there will be any difference in the generated code, since the constructor still has to initialize the int and the pointer.
constexpr guarantees static initialization, and therefore that no additional code needs to run except for the initialization of the int and the pointer. Specifically, that system_category() does not do anything else besides returning a pointer. At present, its straightforward implementation initializes a function-local variable, which is required to be thread-safe and therefore requires synchronization.