Topic: partial specialization of member functions.
Author: pelliott@io.com (Paul Elliott)
Date: 1999/05/22 Raw View
I have a template class which has 2 class template parameters.
The class has a member function which has a template definition
which handles the general case. I want to define a partial
specialization for this member function which will deal
with those cases in which the 1st parameter is a fixed type (=int).
The compiler that I am working with gives me an error message
when I do this, unless I also write an analogous partial
specialization for the template _class_.
What does the standard say? Can I write a partial specialization
for a member function without partially specializing the class
that it is a member of?
Thank You.
--------------
Paul Elliott Telephone: 1(512)837-9345
pelliott@io.com Address: 11900 Metric Blvd Suite J-181
http://www.io.com/~pelliott/pme/ Austin TX 78758-3117
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: sbnaran@dirac.ceg.uiuc.edu (Siemel Naran)
Date: 1999/05/22 Raw View
On 22 May 99 18:51:48 GMT, Paul Elliott <pelliott@io.com> wrote:
>What does the standard say? Can I write a partial specialization
>for a member function without partially specializing the class
>that it is a member of?
Two points of view:
(1) Specializations of nested template classes or nested member
functions is never allowed. Eg,
template <class T> struct A {
template <class U> void f(U) { ... }
template <> void f<int>(int) { ... } // error
};
template <class T> template <> void A<T>::f<double>(double) { ... } // error
(2) Specializations of nested template classes or nested member
functions are allowed only in the class definition.
template <class T> struct A {
template <class U> void f(U) { ... }
template <> void f<int>(int) { ... } // ok
};
template <class T> template <> void A<T>::f<double>(double) { ... } // error
--
----------------------------------
Siemel B. Naran (sbnaran@uiuc.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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]