|
Boost : |
Subject: Re: [boost] [boost::noncopyable] compiler warnings with the -Weffc++ flags
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2009-06-13 12:11:53
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. 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.
-- -Matt Calabrese
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk