 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Matthias Hofmann Guest
|
Posted: Wed Aug 02, 2006 2:44 am Post subject: Using the typename keyword |
|
|
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
|
Posted: Wed Aug 02, 2006 5:48 am Post subject: Re: Using the typename keyword |
|
|
"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 |
|
 |
|
|
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
|
|