|
Boost : |
From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-09-03 15:44:44
----- Original Message -----
From: Daryle Walker <darylew_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Sunday, September 02, 2001 2:22 PM
Subject: [boost] Documenting non-copyable-ness (was: Re: Review:
Boost.Threads)
> on 9/1/01 8:17 PM, Bill Kempf at williamkempf_at_[hidden] wrote:
>
> > --- In boost_at_y..., "Peter Dimov" <pdimov_at_m...> wrote:
> >> From: "William Kempf" <williamkempf_at_h...>
> >>> From: "Peter Dimov" <pdimov_at_m...>
> [SNIP]
> >>>> The reference for many classes indicates that they derive from
> >>>> boost::noncopyable. This implies, AFAICS, that a C-style cast to
> >>>> boost::noncopyable* works. If retained, all such derivations need an
> >>>> 'exposition-only' comment.
> >>>
> >>> They indicate private derivation, so the cast isn't valid. So I'm not
sure
> >>> the comment is needed, but I'm happy to add it.
> >>
> >> The C-style cast is, unfortunately, valid, even when the base class is
> >> inaccessible. (5.4/7)
> >
> > Hmmm... ugly. Can't say as I understand the reasoning for this. In any
> > event, the whole point of boost::noncopyable is to be used in private
> > derivation in this manner, so I wouldn't expect much confusion with
things as
> > they are now. I will, however, add the comment.
> [TRUNCATE]
>
> I haven't looked at the Threads library yet. If you want to say that a
> class is non-copyable in the documentation, then say that directly instead
> of saying that the class derives from boost::noncopyable. Use of
> boost::noncopyable is an implementation detail, and mentioning it may make
> some users try to take advantage of that inheritance.
>
> Also, just saying that a class inherits from boost::noncopyable assumes
that
> the user fully knows about Boost culture, at least about the
> boost::noncopyable class. New users would have no idea what that
> inheritance implies unless they look up boost::noncopyable.
>
I'll take this opportunity to ask this question:
Why isn't noncopyable a template class?
That is:
template<class T>
class noncopyable
{
protected:
noncopyable(){}
~noncopyable(){}
private: // emphasize the following members are private
noncopyable( const noncopyable& );
const noncopyable& operator=( const noncopyable& );
}; // noncopyable
Used as:
struct Some : boost::noncopyable< Some>
{
...
};
just wonder...
Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk