Re: specialization of member functions of class templates

From: Victor Bazarov (v.Abazarov_at_comAcast.net)
Date: 12/25/03


Date: Thu, 25 Dec 2003 16:30:52 GMT


"SainTiss" <stiss@gmx.net> wrote...
> From what I've read in several places, it seems that explicit
specialization
> of member functions of class templates is allowed, but partial
> specialization isn't:
>
> template<class T, class R> class A {
> void foo();
> }
>
> template <>
> void A<int,double>::foo() {} // allowed
>
> template<class T>
> void A<T,double>::foo() {} // forbidden

No, not forbidden. You just have to partially specialise the class
template as well, before you attempt to define the member. 14.5.4.3/1.

> However, when looking for justification in the ISO standard (final draft,
> 1996), it seems the first isn't explicitly allowed in there, and neither
is
> the second explicitly forbidden, even though the first seems to be used in
> an example in 14.5.4.3
>
> So does anyone know what the story is then? Does the standard really
> allow/forbid this or not?

Both are allowed. A partial specialisation of a member requires
the same partial specialisation of the enclosing template to exist.
At least that's how I read the Standard.

Victor



Relevant Pages

  • Re: Full specialization of a member function template of a class template
    ... > a class template. ... "In an explicit specialization declaration for a member of a class ... You can't explicitly specialize a member template of a class template, ...
    (comp.lang.cpp)
  • Re: Create Group Member
    ... Your question sounds there are other templates other than the .eml template. ... Now you will have an envelope icon on your Desktop that when you click on it, you will have a New Message window with your saved opening & member list ready to go. ... I would suggest putting your email address in the To line to keep the Undisclosed Recipients from showing instead which may be filtered upon. ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: pushing the limits of use-before-declaration within a class
    ... > methods or multiple inheritence. ... going to be used again other than being the type of the member c. ... I have a class template that inherits from a class that is a template ... This base class tells the templated class where an array ...
    (comp.lang.cpp)
  • Re: Problem with inheritance and tamplates
    ... your code is a template argument dependant name, ... of a base class that is dependent on a template argument. ... You need to tell the compiler it is a member name, ...
    (comp.lang.cpp)
  • Re: Need help with templates and VC6
    ... Alex Blekhman wrote: ... The support of member templates in VC6 is rather basic. ... VC6 and eVC4 are not able to correctly parse the explicit template arguments ...
    (microsoft.public.vc.language)