|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-03-03 18:32:03
Jonathan Turkanis wrote:
> Hi,
>
> <boost/shared_ptr.hpp> contains the following in the public section
> of the class definition (reformatted):
>
> // Tasteless as this may seem, making all members public
> // allows member templates to work in the absence of member
> // template friends. (Matthew Langston)
>
> #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
>
> private:
>
> template<class Y> friend class shared_ptr;
> template<class Y> friend class weak_ptr;
>
>
> #endif
>
> T * px; // contained pointer
> detail::shared_count pn; // reference counter
>
> This has become a pretty common technique, I believe. I certainly use
> it a lot, at any rate.
>
> I'd like to suggest two macros which would allow code like the above
> to be simplified as follows:
>
> BOOST_PRIVATE:
> BOOST_BEFRIEND_TEMPLATE(shared_ptr, Y, 1)
> BOOST_BEFRIEND_TEMPLATE(weak_ptr, Y, 1)
>
> T * px; // contained pointer
> detail::shared_count pn; // reference counter
This doesn't look any better to me than the original, sorry. ;-)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk