equality of non-type template arguments

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();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top