Topic: C++0x: implicit partial specialization of class templates
Author: pdimov@mmltd.net (Peter Dimov)
Date: Mon, 3 Sep 2001 21:35:46 GMT Raw View
Nicola Musatti <objectway@divalsim.it> wrote in message news:<3B8F84E4.FF13CCA9@divalsim.it>...
> [With apologies if this has been already proposed in the recent past]
>
> I'd like the next revision of the standard to allow implicit partial
> specialization of class templates. That is, given
>
> template <typename A, typename B> struct C {
> int f() { return 2; }
> int g() { return 3; }
> }
>
> the following:
>
> template <typename A> int C<A,int>::f() { return 4; }
>
> Should be taken to imply the following implicit partial specialization
>
> template <typename A> struct C<A,int> {
> int f();
> int g() { return 3; }
> }
>
> in analogy to how the following:
>
> template <> int C<float,int>::f() { return 5; }
>
> is taken to imply
>
> template <> struct C<float,int> {
> int f();
> int g() { return 3; }
> }
This is not exactly the case. Note that
template <> int C<float,int>::f() { return 5; }
does not prevent you to later say
template <> int C<float,int>::g() { return 6; }
whereas your 'implied' version
template <> struct C<float,int> {
int f();
int g() { return 3; }
};
prevents further C<float,int>::g redefinitions.
--
Peter Dimov
Multi Media Ltd.
---
[ 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.research.att.com/~austern/csc/faq.html ]
Author: Nicola Musatti <objectway@divalsim.it>
Date: Tue, 4 Sep 2001 10:31:24 GMT Raw View
Peter Dimov wrote:
[...]
> This is not exactly the case. Note that
>
> template <> int C<float,int>::f() { return 5; }
>
> does not prevent you to later say
>
> template <> int C<float,int>::g() { return 6; }
>
> whereas your 'implied' version
>
> template <> struct C<float,int> {
> int f();
> int g() { return 3; }
> };
>
> prevents further C<float,int>::g redefinitions.
What I meant to say is that given the set of *existing* member
specializations, the missing elements of the corresponding class
template specialization are deduced from the primary class template.
I would like the same behaviour to take place for partial
specializations of class templates and I'd be interested to know if
there are arguments against it.
For one, I'm aware that there is no syntax available to distinguish when
a member partial specialization is part of an explicit partial
specialization from when it is part of an implicit one; this is
currently achieved for complete specializations by either prepending or
omitting "template <>".
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.research.att.com/~austern/csc/faq.html ]
Author: Nicola Musatti <objectway@divalsim.it>
Date: Fri, 31 Aug 2001 16:55:57 GMT Raw View
[With apologies if this has been already proposed in the recent past]
I'd like the next revision of the standard to allow implicit partial
specialization of class templates. That is, given
template <typename A, typename B> struct C {
int f() { return 2; }
int g() { return 3; }
}
the following:
template <typename A> int C<A,int>::f() { return 4; }
Should be taken to imply the following implicit partial specialization
template <typename A> struct C<A,int> {
int f();
int g() { return 3; }
}
in analogy to how the following:
template <> int C<float,int>::f() { return 5; }
is taken to imply
template <> struct C<float,int> {
int f();
int g() { return 3; }
}
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.research.att.com/~austern/csc/faq.html ]