Вот пример, иллюстрирующий вопрос:
Код: Выделить всё
template
struct A { static constexpr int id = N; };
template
struct B { static constexpr int id = N; };
template
void foo();
foo(); // Instantiation 1
foo(); // Instantiation 2
void func() {
struct C { static constexpr int id = unique_id(); }; // Instantiation 3
struct D { static constexpr int id = unique_id(); }; // Instantiation 4
}
Гарантирует ли стандарт C++, что все вызовы unique_id() и связанные с ним экземпляры шаблонов в одной единице перевода происходят в конкретный, предсказуемый порядок?
Подробнее здесь: https://stackoverflow.com/questions/793 ... ons-within