I am constructing derived class from non-copyable base class. I would like to aggregate-initialize Base
in the initializer:
// for convenience, could be any other way to disable copy
#include<boost/noncopyable.hpp>
struct Base: public boost::noncopyable{
int a;
};
struct Derived: public Base{
Derived(int a): Base{a} {}
};
but I am getting:
error: could not convert ‘a’ from ‘int’ to ‘boost::noncopyable_::noncopyable’
As I understand, noncopyable
cannot be initialized, fair enough. Can I then somehow craft the aggregate initializer so that noncopyable initialization is skipped? (I tried e.g. things like Base{{},a}
without real understanding, but that did not work either: ~noncopyable
is protected).
Or will I need to explicitly define Base::Base
which will skip the noncopyable
initialization, using it from Derived::Derived
instead of the aggregate initialization?