Topic: Explicit member template specialization


Author: terje.s@chello.no (=?ISO-8859-1?Q?Terje_Sletteb=F8?=)
Date: Fri, 14 Jun 2002 14:41:56 GMT
Raw View
"Tom Puverle" <tp225@cam.ac.uk> wrote in message news:<abu8fc$d72$1@pegasus.csx.cam.ac.uk>...

> This just seems like such an arbitrary restriction...
>
> template (member) function partial specialization (as mentioned above) feels
> exactly the same way, btw. Why allow it for template classes and not for
> template functions? Enlighten me, please!

This was posted about a month ago, but since no replies have been made
yet, I post this.

This is on the C++ standard core language active issues list
(http://std.dkuug.dk/jtc1/sc22/wg21/docs/cwg_active.html#229)


Regards,

Terje

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: Nicola Musatti <Nicola.Musatti@r-it.it>
Date: Tue, 14 May 2002 17:56:36 GMT
Raw View

Tom Puverle wrote:
>
> What is the reasoning behind not allowing a member template to be explicitly
> specialized without specializing the enclosing template class first?

I'm sure you know that it is possible to *fully* specialize a single
member function of a class template.

I take it you're asking why it isn't possible to partially specialize a
single member function of a class without also partially specializing
the full class, i.e. what you want to do is the following:

template <class C,class D> struct MyClass {
  void f() {}
  void g() {}
};

template <class C> MyClass<C,int>::f() {}

On this I'd also like hear opinions.

Cheers,
Nicola Musatti

---
[ 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://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: "Edward Diener" <eldiener@earthlink.net>
Date: Wed, 15 May 2002 17:52:36 GMT
Raw View
"Nicola Musatti" <Nicola.Musatti@r-it.it> wrote in message
news:3CE109AC.7371E39D@R-it.it...
>
>
> Tom Puverle wrote:
> >
> > What is the reasoning behind not allowing a member template to be
explicitly
> > specialized without specializing the enclosing template class first?
>
> I'm sure you know that it is possible to *fully* specialize a single
> member function of a class template.
>
> I take it you're asking why it isn't possible to partially specialize a
> single member function of a class without also partially specializing
> the full class, i.e. what you want to do is the following:

No, I believe this query is why one can not fully specialize a class
template member function template without fully specializing the class
template first. This isn't the issue of why partial specialization of class
template member functions is not allowed which had been previously brought
up on this NG by me, as much as I would still like to hear the reason(s)
from someone in my original query.


---
[ 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://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: "Tom Puverle" <tp225@cam.ac.uk>
Date: Wed, 15 May 2002 18:20:08 GMT
Raw View
> No, I believe this query is why one can not fully specialize a class
> template member function template without fully specializing the class
> template first. This isn't the issue of why partial specialization of
class
> template member functions is not allowed which had been previously brought
> up on this NG by me, as much as I would still like to hear the reason(s)
> from someone in my original query.

Yes that's correct. I am wondering about the reasoning behind not allowing
things such as:
(Trying the most standard-compatible syntax possible..)
template<>
template<class T>
class Outer<T>::Inner<T> {}

or

template<>
template<class T>
class Outer<T>::Inner<int> {}

(and of course the same goes for member template functions...)

This just seems like such an arbitrary restriction...

template (member) function partial specialization (as mentioned above) feels
exactly the same way, btw. Why allow it for template classes and not for
template functions? Enlighten me, please!
Thanks,
Tom





---
[ 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://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: "Tom Puverle" <tp225@cam.ac.uk>
Date: Mon, 13 May 2002 17:34:04 GMT
Raw View
What is the reasoning behind not allowing a member template to be explicitly
specialized without specializing the enclosing template class first?

Thanks,

Tom


---
[ 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://www.jamesd.demon.co.uk/csc/faq.html                       ]