M
matthias.neubauer
14.4 Type equivalence [temp.type] states, that ...
"Two template-ids refer to the same class or function if [...] their
non-type template-arguments of integral
or enumeration type have identical values ... [..]."
And 14.3.2 Template non-type arguments, para 5 [temp.arg.nontype] says
that
"for a non-type template-parameter of integral or enumeration type,
integral promotions (4.5) and integral
conversions (4.7) are applied."
However, a recent g++ gives me an error (error: could not convert
template argument ‘1’ to ‘E’) when compiling the following translation
unit. After reading the cited paragraphes of the standard I reckon
this would be legal!?!
Regards,
Matthias
enum E {
lab = 1
};
template <E t>
struct C {
void foo();
};
template <>
void C<lab>::foo() {}
void bar () {
C<1> c;
c.foo();
}
"Two template-ids refer to the same class or function if [...] their
non-type template-arguments of integral
or enumeration type have identical values ... [..]."
And 14.3.2 Template non-type arguments, para 5 [temp.arg.nontype] says
that
"for a non-type template-parameter of integral or enumeration type,
integral promotions (4.5) and integral
conversions (4.7) are applied."
However, a recent g++ gives me an error (error: could not convert
template argument ‘1’ to ‘E’) when compiling the following translation
unit. After reading the cited paragraphes of the standard I reckon
this would be legal!?!
Regards,
Matthias
enum E {
lab = 1
};
template <E t>
struct C {
void foo();
};
template <>
void C<lab>::foo() {}
void bar () {
C<1> c;
c.foo();
}