This minimal example compiles without warnings and runs:
// library
template<class T, T t> struct library_struct {};
// user
enum class my_enum { x, y, z };
int main()
{
library_struct<my_enum, my_enum::x> unused; // l.7
(void) unused;
return 0;
}
Now, I want the compiler to deduce the type template parameter my_enum
from the enum template paramter my_enum::x
. This would look much nicer:
library_struct<my_enum::x> unused;
I have seen examples where the compiler was able to deduce template parameters, but I was only allowed to omit the last template parameters in the template parameter lists. So is it possible to omit the enum type here?
EDIT: I'm interested in solutions without macros.