Q: template friend support in VC++ 7 (.NET)

Q: template friend support in VC++ 7 (.NET)

Post by Benjamin Ha » Fri, 11 Oct 2002 08:42:23



I'm in the process of porting a major piece of C++ code from Linux to Windows
CE. The code was developed using g++ > 3.0, and uses extensively STL and
templates. On the first try VC++ 7 gave an arcane error

error C2984: 'Toolbox::_TreeDIterator' : template parameters '<template
parameter>' and '<template parameter>' do not match

to code like this:

template <class T> Foo {
  template <class T_> friend class Bar;

Quote:};

I'd like to ask the experienced if there's any workaround other than code
rewrite/redesign.

BTW it was a problem in VC++ 6.0, and I thought they would've added this long
ago. Why....?

Ben

 
 
 

Q: template friend support in VC++ 7 (.NET)

Post by Nithyanandham » Fri, 11 Oct 2002 09:53:15



> error C2984: 'Toolbox::_TreeDIterator' : template parameters '<template
> parameter>' and '<template parameter>' do not match

> to code like this:

> template <class T> Foo {
>   template <class T_> friend class Bar;
> };

It should be
template <class T> class Foo {
  template <class T_> friend class Bar;

Quote:};

Otherwise, the compiler will get discombobulated.

--

Nithyanand.
Siemens, Bangalore, India.
(Opinions expressed are my own and do not reflect the opinions of my employer,
SIEMENS)

 
 
 

Q: template friend support in VC++ 7 (.NET)

Post by Benjamin Ha » Fri, 11 Oct 2002 11:06:34


Thanks - but that's not the focus here.

(maybe they should put a C++ spelling error in the mail client?)

Ben



> > error C2984: 'Toolbox::_TreeDIterator' : template parameters '<template
> > parameter>' and '<template parameter>' do not match

> > to code like this:

> > template <class T> Foo {
> >   template <class T_> friend class Bar;
> > };

> It should be
> template <class T> class Foo {
>   template <class T_> friend class Bar;
> };

> Otherwise, the compiler will get discombobulated.

> --

> Nithyanand.
> Siemens, Bangalore, India.
> (Opinions expressed are my own and do not reflect the opinions of my employer,
> SIEMENS)

 
 
 

Q: template friend support in VC++ 7 (.NET)

Post by Benjamin Ha » Fri, 11 Oct 2002 11:08:33


Quote:>Thanks - but that's not the focus here.
>(maybe they should put a C++ spelling error in the mail client?)

Oops I mean "spelling checker" (sigh)

Ben



>> > error C2984: 'Toolbox::_TreeDIterator' : template parameters '<template
>> > parameter>' and '<template parameter>' do not match

>> > to code like this:

>> > template <class T> Foo {
>> >   template <class T_> friend class Bar;
>> > };

>> It should be
>> template <class T> class Foo {
>>   template <class T_> friend class Bar;
>> };

>> Otherwise, the compiler will get discombobulated.

 
 
 

Q: template friend support in VC++ 7 (.NET)

Post by NotFoun » Sat, 12 Oct 2002 02:53:35


Benjamin Han escribi:

Quote:

> Thanks - but that's not the focus here.

> (maybe they should put a C++ spelling error in the mail client?)

It's called "copy & paste from tested source".

Regards.

 
 
 

1. friend templates and template friends

Hi,
        I have been looking everywhere, and can't find a solution to
this: How should a class template be declared as a friend?
1. template <class T> friend class A<T>;
2. friend template <class T>  class A<T>;

None of them work in gcc 2.8.0, which I have been using.

JJ

--
JJ Merelo                         | http://kal-el.ugr.es/htbin/jj-plex
Grupo Geneura ---- Univ. Granada  | http://kal-el.ugr.es/


      [ about comp.lang.c++.moderated. First time posters: do this! ]

2. MSN Hotmail Now in Korean, Traditional Chinese And Simplified Chinese Languages

3. template template parameter that VC++ does NOT support

4. Help! Dos TSR and Windows

5. OS/2 AUTOEXEC.BAT analog?

6. vc++ and friends of template classes

7. Companies in Australia!

8. friend template classes in VC++

9. VC++ for NT template/exception support?

10. Does VC++ compiler not support standard template feature ?

11. Member Template Support in VC++

12. use of a template function that is friend to a template class