В качестве примера рассмотрим следующую программу:
Код: Выделить всё
#include
int f() { static int s = 0; return ++s; }
template
struct A {
inline static int i = f(), j = f(), k = f();
};
int main() {
(void)A::j;
auto k = A::k;
auto i = A::i;
auto j = A::j;
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79845281/initialization-order-of-static-variables-in-class-templates[/url]
Мобильная версия