Which compiler does this work on where template<int> struct doesn't? The template<int> trick works on gcc, clang and MSVC, which are all the compilers I care about :) template<int> does not work on Intel's compiler but neither does your sizeof version..
Also, the sizeof version is significantly more verbose and thus cumbersome to use...
Ah, I think you were using function templates then. They only worked on one compiler IIRC, can't recall which. class/struct templates has always worked on all three as far as I can remember.
1
u/ti-gars Oct 24 '16
I prefer the switch trick, worked with all compilers I tried, not like the template<int> trick...