C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using the typename keyword

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Matthias Hofmann
Guest





PostPosted: Wed Aug 02, 2006 2:44 am    Post subject: Using the typename keyword Reply with quote



Hello everybody!

The typename keyword still confuses me, so I went through section 14.6 of
the standard and now I am pretty sure that the typename keyword is required
twice in the following example:

template <class T> std::vector<typename T::value_type> f( const T& x )
{
return std::vector<typename T::value_type>( x.begin(), x.end() );
}

However, I am not absolutely sure, so please have a look at the function
template above and tell me whether the use of the typename keyword is
correct. Thanks in advance,

--
Matthias Hofmann
Anvil-Soft, CEO
http://www.anvil-soft.com - The Creators of Toilet Tycoon
http://www.anvil-soft.de - Die Macher des Klomanagers



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
W. J. La Cholter
Guest





PostPosted: Wed Aug 02, 2006 5:48 am    Post subject: Re: Using the typename keyword Reply with quote



"Matthias Hofmann" <hofmann@anvil-soft.com> wrote in
news:44cfb863$0$24887$9b4e6d93 (AT) newsread4 (DOT) arcor-online.net:

Quote:
The typename keyword still confuses me, so I went through section 14.6
of the standard and now I am pretty sure that the typename keyword is
required twice in the following example:

template <class T> std::vector<typename T::value_type> f( const T& x )
{
return std::vector<typename T::value_type>( x.begin(), x.end() );
}

However, I am not absolutely sure, so please have a look at the
function template above and tell me whether the use of the typename
keyword is correct. Thanks in advance,

Yes, it is correct. T::value_type is a dependent name, i.e., it's
resolution depends on the definition of T, and therefore requires the
typename keyword.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.