Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-09-30 12:29:47


"Powell, Gary" <powellg_at_[hidden]> writes:

> Well depends whether you prefer and can compile.
>
> template<class T>
> class shifted_ptr {
> public:
> template<class U, class Arg1>
> friend shifted_ptr<T> make_shifted_ptr();
>
> template<class U, class Arg1>
> friend shifted_ptr<T> make_shifted_ptr(Arg1 &);
>
> template<class U, class Arg1, class Arg2>
> friend shifted_ptr<T> make_shifted_ptr(Arg1 &, Arg2 &);
> ....
> };
>
> Or the other way. If I remember correctly not all compilers used to
> be able to handle template friends. On the other hand the previous
> approach could have been due to a lack of caffeen.
>
> So after looking at this for all of 5 minutes, if the friend
> make_shifted_ptr works, it looks easier to maintain. But in all
> cases taking raw pointers is to be avoided.

Well it's far terser to grant friendship to an undocumented backdoor
friend class which does the job, like we do in the iterator library,
but that's the basic principle.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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