|
Boost : |
Subject: Re: [boost] [boost::noncopyable] compiler warnings with the -Weffc++ flags
From: David Abrahams (dave_at_[hidden])
Date: 2009-06-18 21:01:54
on Sat Jun 13 2009, Matt Calabrese <rivorus-AT-gmail.com> wrote:
> Perhaps slightly off topic, but I seem to remember a couple of years ago
> Sean Parent pointing out that noncopyable might be better implemented with
> CRTP.
Ironic, since in Sean's world, all types are copyable :-)
> Has this been forgotten? I think the rationale was that if you have
> one child which inherits from two or more bases that inherit from the
> current noncopyable, the empty base optimization can't be used since each of
> the noncopyable bases have to have different addresses, so your type's size
> grows with each additional base that inherits from noncopyable. As well, I
> believe that certain compilers were producing spurious warnings if you use
> such multiple inheritance, suggesting to the programmer that noncopyable may
> be better as a virtual base (which it clearly would not). Making a
> noncopyable template, perhaps called noncopyable_ so that the two can
> coexist, that is implemented the same way but whose intended use is to be
> instantiated with the child type fixes these problems by making certain that
> all noncopyable bases in a hierarchy have different types, meaning that EBO
> may be used and there are no duplicate noncopyable bases.
Yeah, it's an issue, but I'm not sure it's worth improving. I view
noncopyable as a quick fixup for people doing traditional OO-style
programming. I'm open to arguments, though.
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk