Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2001-05-15 07:33:08


on 5/14/01 7:20 AM, Bill Seymour at bsey_at_[hidden] wrote:

> - I agree that functions such as abs() should be friends,
> not members. I'm concerned, though, that some compilers
> can't handle template friends. As a compromise, I suggest
> leaving such functions in the class as helpers for the free
> functions, and either leaving them undocumented or (better IMO)
> documenting them as implementation details that have to be
> public for portability to non-conforming implementations.
[SNIP]

Doesn't the problem with template friends come up when we want the
friendship to be templated, like this:

class my_class
{
    //...
    template < typename T > friend void my_func<T>( T& );
    template < typename U > friend class my_class2<U>;
};

It doesn't count otherwise; especially when it's a non-template friend
depending on the outer class's template parameters:

template < typename T, int N >
class my_class
{
    //...
    friend int my_func<N>( void );
    friend class my_class2<T>;
};

We would need the second type, where only the corresponding version of abs<>
would be a friend to decimal<>. That doesn't count as a template friend.

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

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