[bind10-dev] boost non-copyable

JINMEI Tatuya / 神明達哉 jinmei at isc.org
Tue May 25 17:51:43 UTC 2010


At Tue, 25 May 2010 09:03:56 +0800,
han benjamin <ben.han.cn at gmail.com> wrote:

> If the code dependency is one concern, we can write our own
> noncopyable base class. There is no magic in
> the boost::noncopyable. It's quite easy:
> 
> class noncopyable
>   {
>    protected:
>       noncopyable() {}
>       ~noncopyable() {}
>    private:  // emphasize the following members are private
>       noncopyable( const noncopyable& );
>       const noncopyable& operator=( const noncopyable& );
>   };
> 
> There are two reasons I think we should use it.  One is to eliminate
> the duplication, the other one is that
> for others even they have no background knowledge about c++, he can
> easily understand what your intension
> when you inherit from noncopyable instead of declaring two private functions.

Hmm, personally I'm still not so sure if the advantage outweighs the
overhead of developing an in-house tool.  In fact we could also say if
someone without background knowledge of C++ needs to read our code,
private inheritance (and multiple inheritance if the non-copyable
class is already inherited as part of the class design) are something
that person will learn last.  Besides, whether or not we use a
separate class, IMO we should document the intent anyway, covering why
the class can and/or should be non-copyable (I generally try to
provide that information in the DNS library).

That said, I also see there's certainly some advantage, and since we
already use some internal inter-module dependency (e.g. for our
derived exception classes), the overhead of adding one more wrt
dependency management may be marginal.

So, if you strongly implement it, I wouldn't oppose to that.  In that
case please make a ticket for it, work on it in a branch, and get it
reviewed and merged.

---
JINMEI, Tatuya
Internet Systems Consortium, Inc.



More information about the bind10-dev mailing list