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

Refering to a template name

Hello,

template <class T>
class weak_ptr
{
weak_ptr(weak_ptr const &r);
};

In the code above, a parameter of type weak_ptr is declared. How is this
possible? weak_ptr is not a type, it's a template! How can me use the name
of a template as a data type?

Thanks,
Dave
Jul 22 '05 #1
2 1072
Dave wrote:
Hello,

template <class T>
class weak_ptr
{
weak_ptr(weak_ptr const &r);
};

In the code above, a parameter of type weak_ptr is declared. How is this
possible? weak_ptr is not a type, it's a template! How can me use the name
of a template as a data type?


For use inside a template definition you can ommit the type used, so the
above could also have been written as:
template <class T>
class weak_ptr
{
weak_ptr<T>(weak_ptr<T> const &r);
};

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 22 '05 #2
Dave wrote in news:10*************@news.supernews.com in comp.lang.c++:

template <class T>
class weak_ptr
{
weak_ptr(weak_ptr const &r);
};

In the code above, a parameter of type weak_ptr is declared. How is
this possible? weak_ptr is not a type, it's a template! How can me
use the name of a template as a data type?


In effect within the scope of weak_ptr< T > weak_ptr is an
alias for weak_ptr< T >.

I can't offhand remember the exact (standard text) of how this
is done, but it is.

IOW: That is how C++ is specified, the alternative would be:

template < typename T >
struct X
{
X< T >( X< T > const &x );
};

Which is just more typing, with no (AFAICT) percivable benefit.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #3

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

Similar topics

2
by: Alex Vinokur | last post by:
========================================= Windows 2000 CYGWIN_NT-5.0 1.3.22(0.78/3/2) GNU gcc version 3.2 20020927 (prerelease) ========================================= Here is some program...
3
by: Rennie deGraaf | last post by:
The attached code compiles and works properly when I comment out the declaration, definition, and invocations of the method 'eck'. With "eck" in there, g++ fails with ttest.cpp:23: template-id...
4
by: Mikael Petterson | last post by:
Hi, I got some help to go from: bbBusState to BB_BUS_STATE. However I found out :-( that the xml contained attributes like: TxDeviceGroup and that becomes:
2
by: Remi COCULA | last post by:
When using xsl:call-template it seems that we can't use a parameter as the name of the template to call. Example : <xsl:template name="cadre"> <xsl:param name="p_contenu"/> ...
1
by: Julien Phalip | last post by:
Hi everyone! I am trying to do a transformation from the xml file: <foo> <attribute>a</attribute> ... </foo> The xsl file is as follows:
2
by: Anna | last post by:
Hi all. I am trying to write a stylesheet that will structure the input HTML file in the following way: For each heading of level n it needs to enclose the heading and all its content until the...
7
by: Thomas Matthews | last post by:
Hi, I am converting my table and record classes into templates. My issue is the syntax of declaring a friend class within the template. I have searched the C++ FAQ Lite (web), the C++...
5
by: Alex Maghen | last post by:
I frequently find myself wanting to insert some basic client-side JavaScript functions in the page of an ASPX of mine. But I find it so frustrating that I have to actually contruct my JavaScript in...
4
by: danilo.turina | last post by:
Hi all, today I encountered a problem that I'm only able to solve by using reinterpret_cast (and I'd like to avoid it). This was my code until yesterday (omitting includes, "using namespace"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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...

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.