473,414 Members | 1,948 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,414 software developers and data experts.

14.7.1.(9) from the C++ standard

14.7.1.(9) from the C++ standard: "An implementation shall not
implicitly instantiate a function template, a member template, a
nonvirtual member function, a member class or a static data member of
a class template that does not require instantiation"

Here, what does 'member template' mean ?

In the above statement, kindly explain the line(if possible please
give an example)
"a member class or a static data member of a class template that does
not require instantiation"

Thanks
V.Subramanian

Nov 5 '07 #1
3 1278
su**************@yahoo.com wrote:
14.7.1.(9) from the C++ standard: "An implementation shall not
implicitly instantiate a function template, a member template, a
nonvirtual member function, a member class or a static data member of
a class template that does not require instantiation"

Here, what does 'member template' mean ?
template<class Tclass A {}; // class template
template<class Tvoid foo(T); // function template
template<class Tclass B {
void foo(); // non-virtual function
static int i; // data member
template<class Tint blah(); // member template
template<class Tclass S {}; // member template
};
In the above statement, kindly explain the line(if possible please
give an example)
"a member class or a static data member of a class template that does
not require instantiation"
If the class template that doesn't require instantiation (never used
in the program in such way that would cause instantiation), a member
template of that class [template] and other elements that are really
templates, shouldn't require instantiation either. To keep the code
from being bloated from the unnecessary instantiations of the class
members the Standard explicitly prohibits those. At least that's how
I read it.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 5 '07 #2
Victor Bazarov wrote:
:: su**************@yahoo.com wrote:
::: 14.7.1.(9) from the C++ standard: "An implementation shall not
::: implicitly instantiate a function template, a member template, a
::: nonvirtual member function, a member class or a static data
::: member of a class template that does not require instantiation"
:::
::: Here, what does 'member template' mean ?
::
:: template<class Tclass A {}; // class template
:: template<class Tvoid foo(T); // function template
:: template<class Tclass B {
:: void foo(); // non-virtual function
:: static int i; // data member
:: template<class Tint blah(); // member template
:: template<class Tclass S {}; // member template
:: };
::
::: In the above statement, kindly explain the line(if possible please
::: give an example)
::: "a member class or a static data member of a class template that
::: does not require instantiation"
::
:: If the class template that doesn't require instantiation (never
:: used in the program in such way that would cause instantiation), a
:: member template of that class [template] and other elements that
:: are really templates, shouldn't require instantiation either. To
:: keep the code from being bloated from the unnecessary
:: instantiations of the class members the Standard explicitly
:: prohibits those. At least that's how I read it.
::

It also saves you from the problem that some members, like perhaps
foo(), cannot be instantiated for all T's. This is not an error,
unless someone actually calls foo() for that T.
Bo Persson
Nov 5 '07 #3
On Nov 5, 3:52 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:

template<class Tclass A {}; // class template
template<class Tvoid foo(T); // function template
template<class Tclass B {
void foo(); // non-virtual function
static int i; // data member
template<class Tint blah(); // member template
template<class Tclass S {}; // member template
};
I'm not sure what the standard says, but the code here
above does not compile on GCC 4+ as well as Comeau
online.

"ComeauTest.c", line 7: error:
template parameter "T" may not be redeclared in this scope

template<class Tclass S {}; // member template

where scope is the scope of B. Code below fixed this - maybe
the mistake is just a small oversight.

template<class Tclass B {
void foo(); // non-virtual function
static int i; // data member
template<class Uint blah(); // member template
template<class Uclass S {}; // member template
};

Regards,

Werner

Nov 5 '07 #4

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

Similar topics

25
by: Magnus Lie Hetland | last post by:
Is there any interest in a (hypothetical) standard graph API (with 'graph' meaning a network, consisting of nodes and edges)? Yes, we have the standard ways of implementing graphs through (e.g.)...
6
by: John Bentley | last post by:
John Bentley writes at this level: If we think about our savings accounts then division never comes in (as far as I can see). We deposit and withdraw exact amounts most of the time. Occasionaly...
29
by: David Eng | last post by:
In replying to P.J. Plauger (...
43
by: Steven T. Hatton | last post by:
Now that I have a better grasp of the scope and capabilities of the C++ Standard Library, I understand that products such as Qt actually provide much of the same functionality through their own...
52
by: lovecreatesbeauty | last post by:
Why the C standard committee doesn't provide a standard implementation including the C compiler and library when the language standard document is published? C works on the abstract model of low...
24
by: noridotjabi | last post by:
Why isn't there a Graphical User Interface standard? Think about it for a second. You may say, well evey systems API for GUIs is differnt, but do take into acound: every operating system requires...
132
by: Frederick Gotham | last post by:
If we look at a programming language such as C++: When an updated Standard comes out, everyone adopts it and abandons the previous one. It seems though that things aren't so clear-cut in the C...
1
by: manish deshpande | last post by:
Hi, When i'm installing MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm by the following command: rpm -i MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm the following error is being shown: ...
26
by: Rick | last post by:
I'm told that "#pragma once" has made it into the ISO standard for either C or C++. I can't find any reference to that anywhere. If it's true, do any of you have a reference I can use? ...
270
by: jacob navia | last post by:
In my "Happy Christmas" message, I proposed a function to read a file into a RAM buffer and return that buffer or NULL if the file doesn't exist or some other error is found. It is interesting...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.