Thread View: comp.std.c++
1 messages
1 total messages
Started by Ben Werther
Fri, 29 Sep 1995 16:06
Templated constructors
Author: 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. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads