mardi 3 juillet 2018

Inherited constructor, compiles in clang++3.9, fails in g++ 7

This code snippet

struct Base{};
struct Derived: Base{
    using Base::Base;
};

int main() 
{
    Base b;
    Derived d{b};
}

compiles fine on clang++3.9, however it fails on all gcc's (including 7) and clangs with versions smaller than 3.9 with the error msg

error: no matching function for call to 'Derived::Derived() Derived d{b}'.

Is the code above standard compliant or not?

PS: if I comment out the using Base::Base line, the code does not compile anymore on clang-3.9.

Aucun commentaire:

Enregistrer un commentaire