|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-09-17 21:19:12
----- Original Message -----
From: <jeremy_at_[hidden]>
> Today I discovered boost.org and I must say that it will take a long
> time before I fully appreciate everything at this wonderful site.
>
> I am having a slight problem with noncopyable and I'm curious if
> anyone can help me out. I have a concrete base and derived class and
> I want both to be noncopyable:
> class A : noncopyable {};
> class B : public A, noncopyable {};
>
> MSVC 6 sp5 gives error C2584 'B' : "direct base 'noncopyable' is
> inaccessible; already a base of 'A'"
>
> while gcc 2.95.2 gives test.cpp:3: warning: direct base `noncopyable'
> inaccessible in `B' due to ambiguity
>
> I'm assuming that inside B, there is no way to refer to noncopyable
> without ambiguity, and the compilers don't like that. It would be
> nice if I got a warning that I could suppress, but MSVC calls this an
> error.
MSVC is wrong to give you an error, unless you have "all warnings are
errors" enabled and you have MSVC set to warn about this.
Although it is notoriously difficult to tune GCC warnings on a case-by-case
basis, it seems like you should be able to turn this one off.
> If this is true, I suppose I can make noncopyable a virtual base
> class in situations like this (will this add any overhead if
> noncopyable has no data members??).
Yes and yes.
> I could also make a noncopyable2
> which is the same as noncopyable.
I think you can just derive noncopyable2 from noncopyable.
> I can't say I particularly like
> either of these options :(.
Then you can try to disable the warnings... ;-)
HTH,
Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk