[bind10-dev] noncopyable classes
Stephen Morris
stephen at isc.org
Mon Feb 14 09:44:51 UTC 2011
On 14/02/2011 09:37, Jelte Jansen wrote:
>
> Hi,
>
> we have certain classes that we want to be noncopyable, and so far I've seen two
> different ways to do this;
>
> 1. make it a subclass of boost::noncopyable
> 2. make the copy constructor and the assignment operators private
>
> The first is slightly shorter, but the second is not that much more work, and it
> has the slight advantage that it at least gets rid of one dependency on boost in
> our headers.
>
> And of course for the sake of consistency it's better to only use one method
> here, so I'd like to propose we update the coding guidelines to use method 2 for
> this.
>
> Any thoughts?
I'm inclined to go for (2). boost::nocopyable is more elegant, but not
much clearer if the fact that the class is non-copyable is clearly
documented. Also, as well as avoiding a dependency on boost, we avoid
multiple inheritance if we want to make a derived class non-copyable.
Stephen
More information about the bind10-dev
mailing list