This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++0x]: non-public defaulted copy c-tor


Jonathan Wakely wrote:

> This is DR906
> http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#906

Thanks.

> Note "it shall be public"

And what's the reason for such restrictions?
I've used the following construction as a very
useful idiom to create an abstract class:

    class Base {

    protected:

        Base() = default;
        virtual ~Base() = default;
    };

    class Derived : public Base {

    public:

        Derived() { ... }
        virtual ~Derived()  { ... }
    };

Clean, simple and GCC used to happily accept that.
But now it is illegal because of 3 draft violations:

Base() shall be public, but is not
~Base() shall be public, but is not
~Base() shall not be virtual, but it is

IMHO this severely cripples defaulted functions,
making them almost useless -- the set of allowed
cases is too narrow. Is there any chance to fix the DR?

Best regards
Piotr Wyderski


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]