Topic: Template Member Specialization?
Author: Imran Haq <ihaq@mit.edu>
Date: 1996/05/21 Raw View
Does anyone know the status of defining template member functions within
a class definition without making the class itself templated?
[This is allowed by the draft C++ standard, but it is a relatively
recent language extension and most compilers don't support it yet.
-Moderator (fjh).]
In other words, can one write:
class my_class {
...
my_class(Iterator,.....)
...
};
template <class Iterator>
my_class::my_class(Iterator,....) { .... };
Is this legal in the draft standard?
[You didn't get the syntax quite right -- you need to insert
`template <class Iterator>' in the class declaration too, i.e.
class my_class {
...
template <class Iterator>
my_class(Iterator,.....)
...
};
But other apart from that, yes, it is legal. -mod.]
On a related point, does anyone know
of a work-around to defining a structure similar to this, subject to the
limitations of today's compilers?
[Followups on that question to comp.lang.c++.moderated, please. -mod.]
Imran Haq
ihaq@mit.edu
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]