Topic: Templated constructors
Author: Ben Werther <benw@cs.monash.edu.au>
Date: 1995/09/29 Raw View
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. ]