Re: Templates and Copy Constructors. Again.
From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 02/23/05
- Next message: Kurt Stutsman: "Re: How to redefine operator delete/delete[] via macro?"
- Previous message: Dietmar Kuehl: "Re: C++ FAQ"
- In reply to: Matt Bitten: "Re: Templates and Copy Constructors. Again."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 22 Feb 2005 21:34:08 -0500
"Matt Bitten" <mbitten73@yahoo.com> wrote...
> Now, what is it that is NOT a copy constructor, that has everyone so
Everyone? I'd probably refrained from speaking for *everyone*...
> confused? I read in the standard in 12.8 that a "template
> constructor" is not a copy constructor. However, a global search of
> the standard turns up no other use of the term "template
> constructor". So what is a template constructor?
> [...]
> It is not clear to me that this is what the standard says, however.
class Foo {
public:
template<class T> Foo(T const& t); // a template constructor
};
template<class T> class Bar {
public:
template<class U> Bar(const Bar<U>&); // a template constructor
};
The point is that in neither case the template constructor implements
or works in lieu of the compiler-generated copy constructor, although
you might think that if in the first case "T" is Foo, then the c-tor
becomes
Foo(Foo const& t);
and in the second case if U is the same as T, then it becomes
Bar<T>(const Bar<T>&);
The Standard says that it's not going to happen. In both classes Foo
and Bar<T>, the copy constructor that has a very specific signature
is going to be provided and will take over for all copy-construction
needs.
Victor
- Next message: Kurt Stutsman: "Re: How to redefine operator delete/delete[] via macro?"
- Previous message: Dietmar Kuehl: "Re: C++ FAQ"
- In reply to: Matt Bitten: "Re: Templates and Copy Constructors. Again."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|