usage of keyword template / standard

  • Thread starter Alexander Stippler
  • Start date
A

Alexander Stippler

Hi,

I'm not quite sure if I have to use the keyword template in a situation,
where my compiler enforces it, though I think it is not neccessary. My
question is: Who is wrong with respect to the standard - the compiler or I?

template <typename T>
struct A
{
template <typename C>
bool
test();

static size_t value = sizeof(A<T>::test<T>());
};

Do I need to qualify test by 'template'. IMO no.
It would be different in a context like
sizeof(T::template test<T>())
Am I wrong?

regards,
alex
 
A

Attila Feher

Alexander said:
Hi,

I'm not quite sure if I have to use the keyword template in a
situation, where my compiler enforces it, though I think it is not
neccessary. My question is: Who is wrong with respect to the standard
- the compiler or I?

template <typename T>
struct A
{
template <typename C>
bool
test();

static size_t value = sizeof(A<T>::test<T>());
};

Do I need to qualify test by 'template'. IMO no.
It would be different in a context like
sizeof(T::template test<T>())
Am I wrong?

You are. A<T> is also dependent on T.
 
A

Attila Feher

Attila Feher wrote:
[SNIP]
You are. A<T> is also dependent on T.

From the standard, where it says what is dependent:

— a templateid in which either the template name is a template parameter or
any of the template arguments is a dependent type or an expression that is
typedependent
or valuedependent.

Clearly A is a template ID and the template argument is clearly a dependent
type.
 

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

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,362
Latest member
ChandaWagn

Latest Threads

Top