This question is similar to this one, but more specific to pre-c++11 scenarios.
I've noticed with Clang and g++ that the following compiles and works fine with pre-c++11:
enum En { V0 = 0 };
template <int SZ> class C { };
template <En EN> class E { };
int main() {
const int SIZE = 42;
C<SIZE> c;
const int SIZE2 = SIZE ^ 0xDEADBEEF;
C<SIZE2> c2;
const En E1 = V0;
E<E1> e1;
}
In a context where no constexpr is available, doing this is incredibly convenient, perhaps even necessary in some cases. So is this guaranteed to work, or are g++ and Clang just inferring these values for convenience?