473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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
Jul 19 '05 #1
2 1464
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
Jul 19 '05 #2
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
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Aaron Anodide | last post by:
Hello, I am using the following template class as a shorthand for zero-ing memory: template<class T> class ZeroMem : public T { public: ZeroMem(void)
13
by: DarkSpy | last post by:
many c++ compilers including "gcc" have not implemented the "export" keyword, but the comeau compilers made it (just i knew). i want to know about: is it too difficult to implement "export"...
2
by: Anonymous | last post by:
I'm trying to port code from VC.net to VC.net 2003. Here's a typical piece of code that's often used: template<class T> class PseudoContainer { typedef T::iterator iterator; // this line will...
3
by: sks | last post by:
Hello all Is the usage of extern keyword valid for telling the compiler to NOT instantiate a template and to link it from an another binary? For example: Suppose module A's binary contains a...
2
by: Dilip | last post by:
Folks I understand that the keyword typename is also used to indicate that a dependant parameter is a type. However I am a little unsure why I need typename in this following example: ...
3
by: Veeru | last post by:
i have one structure SPageDetails. i have a template class CStack. Now i have a pointer of this stack class in another class "CAnotherClass" as: class CAnotherClass {...
2
by: adrian.hawryluk | last post by:
Hi everyone, I've been using templates for a while, but I'm not at full power yet (knowledge=power) ;). Does anyone know where I can get information on this 'new' template usage? template<a...
22
by: nospam_news | last post by:
I currently get asked about my usage of "auto". What is it for? The keyword is clearly superflous here. In contrast to the huge majority of C/C++ developers I write definitions very explicitly...
51
by: muktipada | last post by:
Hello, As a C++ developer which one we should use for pointer assignment, NULL or 0. typedef DummyC DummyClass*; // in some header file. DummyC obj = NULL; if (obj == NULL) {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.