Boost logo

Boost :

From: Henrik Ravn (henrik_at_[hidden])
Date: 2001-11-04 15:49:48


Hi,

> I like a nidea presented, but I am not sure that implementation is
> portable. As far as I remember following friend declaration is ill-
> formed:
>
> template<class T>
> class A {
> friend class T;
> };
>
> I do not have an access to Standart and can't find information online
> (other than
> http://www.prismtk.de/docs/software/cseq/cxxdontpanic_76.html#SEC76),
> so I would like to here a word from expert in this area. Anyway MSVC
> does not compile your example.
Yeah, I found out. I originally wrote this on MSVC (without the 'class')
and then I tested it on CodeWarrior 7 for Windows, which complained
about a bad friend declaration. I added the 'class' and it worked. Just
before I uploaded I checked it on MSVC which (probably because of
precompiled headers) didn't blink an eye. So I uploaded. But now, after
a forced rebuild, I also get the error. :-(

So it seems CW 7 for Windows has got it wrong and MSVC has got it right.
CW7 and MSVC6 are the only compilers I have access to, does anyone know
how other compilers fare here? And has anyone got a workaround for CW7
other than:
#ifdef __MWERKS__
        friend class Owner;
#else
        friend Owner;
#endif

????

BTW, I just uploaded an updated version containing the #ifdef's
mentioned above, so now it compiled both on MSVC6 and CW7.

> If we would be able to find portable solution I will vote for
> adding this cool classes into utility section.
Thanx.

>I would also add more
> argument(s) to be able to specify additional "freind" classes.
Why? The friend declaration is really just a way of letting the
containing class get access to the innards of the property. Wouldn't it
be counterproductive to let more classes in? I'm not really against it,
just curious as to why ... how many do you think would be needed?

Best
Henrik

>
> Regards,
>
> Gennadiy.
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk