Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #71209
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: explicit specialization problem |
| Date | 2020-01-08 10:26 +1300 |
| Message-ID | <h7kbblFsqhkU3@mid.individual.net> (permalink) |
| References | <qv1mcf$vi4$1@news.albasani.net> |
On 07/01/2020 23:26, Bonita Montero wrote:
> Why does this work with an older g++ (6.3.0) and not with MSVC:
>
> #include <iostream>
>
> using namespace std;
>
> template<typename T>
> struct My
> {
> };
>
> template<typename T>
> struct Lib
> {
> void f();
> };
>
> template<typename T>
> void Lib<T>::f()
> {
> cout << "void Lib<T>::f()" << endl;
> }
>
> template<>
> template<typename T>
> struct Lib<My<T>>
> {
> void f();
> };
>
> template<typename T>
> void Lib<My<T>>::f()
> {
> cout << "void Lib<My<T>>::f()" << endl;
> }
>
> int main()
> {
> Lib<My<int>> lmi;
> lmi.f();
> }
>
> MSVC:
> x.cpp(22): error C2910: 'Lib<My<T>>': cannot be explicitly specialized
> x.cpp(31): error C2039: 'f': is not a member of 'Lib<My<T>>'
> x.cpp(30): note: see declaration of 'Lib<My<T>>'
> x.cpp(31): error C2447: '{': missing function header (old-style formal
> list?)
Use a more friendly compiler...
$ clang++ -std=c++17 /tmp/x.cc
/tmp/x.cc:22:1: warning: extraneous template parameter list in template
specialization
template<>
^~~~~~~~~~
--
Ian.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
explicit specialization problem Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-07 11:26 +0100
Re: explicit specialization problem Ian Collins <ian-news@hotmail.com> - 2020-01-08 10:26 +1300
Re: explicit specialization problem "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2020-01-07 23:23 +0100
Re: explicit specialization problem Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-08 07:29 +0100
Re: explicit specialization problem "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-01-07 22:34 -0800
Re: explicit specialization problem Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-08 07:46 +0100
Re: explicit specialization problem Öö Tiib <ootiib@hot.ee> - 2020-01-07 22:58 -0800
Re: explicit specialization problem Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-08 10:36 +0100
Re: explicit specialization problem Öö Tiib <ootiib@hot.ee> - 2020-01-08 03:56 -0800
Re: explicit specialization problem Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-08 13:00 +0100
Re: explicit specialization problem Öö Tiib <ootiib@hot.ee> - 2020-01-08 06:02 -0800
Re: explicit specialization problem Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-08 15:15 +0100
Re: explicit specialization problem Öö Tiib <ootiib@hot.ee> - 2020-01-08 06:48 -0800
Re: explicit specialization problem Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-08 15:53 +0100
Re: explicit specialization problem Öö Tiib <ootiib@hot.ee> - 2020-01-08 07:16 -0800
Re: explicit specialization problem Manfred <noname@add.invalid> - 2020-01-08 16:28 +0100
Re: explicit specialization problem Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-08 15:00 +0000
Re: explicit specialization problem "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-01-08 14:44 -0800
Re: explicit specialization problem Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-09 02:20 +0000
Re: explicit specialization problem "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-01-08 19:42 -0800
Re: explicit specialization problem Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-09 18:17 +0000
Re: explicit specialization problem Jorgen Grahn <grahn+nntp@snipabacken.se> - 2020-01-09 19:40 +0000
Re: explicit specialization problem Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-09 21:21 +0000
csiph-web