Article View: comp.std.c++
Article #2076Templated constructors
From: Ben Werther
Date: Fri, 29 Sep 1995 16:06
Date: Fri, 29 Sep 1995 16:06
46 lines
2453 bytes
2453 bytes
The WP seems to leave open the possibility of having templated constructors.
However it does not mention them explicitly anywhere. If they are possible,
then it seems to me that an ambiguity exists. If the following is not legal
then I would appreciate knowing why, as this area is on the fringes of what
is covered in the WP.
If we have a templated constructor of a template, then I believe it would
be written as so:
template<class T>
class myClass {
public:
// The constructor declaration
template<class T2> myClass(T2&);
// A specialization declaration
myClass<int>(int&);
// however, is this <int> referring to a specialization of class
// myClass (T is int), where the declaration is a non-explicit
// specialization, or is <int> referring to the constructor
// (T2 is int), where it is an explicit specialization.
// A dubious specialization
myClass<int><int>(int&);
// Here both T and T2 are specialized to int.
};
I find it hard to believe that this syntax would be desired, but is it
legal? If so, then there appears to be an ambiguity.
Ben.
-===============================================================-
- Ben Werther - Email: benw@cs.monash.edu.au -
- Department of Computer Science - Work ph: +613 9905 5191 -
- Monash University - -
- Melbourne, Australia - -
-===============================================================-
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<199509291600.CAA18028@indy06.cs.monash.edu.au>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: Ben Werther <benw@cs.monash.edu.au> Newsgroups: comp.std.c++ Subject: Templated constructors Date: 29 Sep 1995 16:06:49 GMT Organization: ? Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <199509291600.CAA18028@indy06.cs.monash.edu.au> NNTP-Posting-Host: taumet.eng.sun.com Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII"; conversions="7bit" Content-Transfer-Encoding: 7bit X-Mailer: ELM [version 2.4 PL23] X-Lines: 42 Content-Length: 1632 Originator: clamage@taumet