Tuesday, January 7, 2020

Digest for comp.lang.c++@googlegroups.com - 3 updates in 2 topics

Ian Collins <ian-news@hotmail.com>: Jan 08 10:26AM +1300

On 07/01/2020 23:26, Bonita Montero wrote:
> 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.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jan 07 11:23PM +0100

On 07.01.2020 11:26, Bonita Montero wrote:
> {
>     void f();
> };
 
The `template<>` does not make sense here.
 
Just remove that line.
 
 
> x.cpp(30): note: see declaration of 'Lib<My<T>>'
> x.cpp(31): error C2447: '{': missing function header (old-style formal
> list?)
 
I get the same diagnostics with MSVC 2019.
 
With MinGW g++ 9.2:
 
_.cpp:25:8: error: too many template-parameter-lists
25 | struct Lib<My<T>>
| ^~~~~~~~~~
_.cpp:31:20: error: invalid use of incomplete type 'struct Lib<My<T> >'
31 | void Lib<My<T>>::f()
| ^
_.cpp:12:8: note: declaration of 'struct Lib<My<T> >'
12 | struct Lib
| ^~~
 
When the offending `template<>` is removed both compilers accept the code.
 
 
- Alf
Bonita Montero <Bonita.Montero@gmail.com>: Jan 07 07:50PM +0100

>> It fails to compile on older C++ compilers, before C++11
 
> It should fail to compile with compilers that enforce good taste.
 
auto isn't good taste except when necessary.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: