usage of keyword template / standard



 DEVELOP > c-Plus-Plus > usage of keyword template / standard

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "Alexander Stippler"
Date: 03 Sep 2003 07:33:47 AM
Object: usage of keyword template / standard
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
.

User: "Attila Feher"

Title: Re: usage of keyword template / standard 03 Sep 2003 07:40:18 AM
Alexander Stippler wrote:

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.
--
Attila aka WW
.
User: "Attila Feher"

Title: Re: usage of keyword template / standard 03 Sep 2003 07:44:26 AM
Attila Feher wrote:
[SNIP]

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.

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.
--
Attila aka WW
.



  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER