struct B {
B(int) {}
B(B const&) {}
};
struct D: B {
using B::B;
};
int main(void) {
B b(5);
D d(b); // error
return 0;
}
c++14 explicitly excludes copy/move constructors from inherited constructors in 12.9 [class.inhctor]/p3.
For each non-template constructor in the candidate set of inherited constructors other than a constructor having no parameters or a copy/move constructor having a single parameter, a constructor is implicitly declared with the same constructor characteristics unless there is a user-declared constructor with the same signature in the complete class where the using-declaration appears or the constructor would be a default, copy, or move constructor for that class.
But I could not find any detailed descriptions in c++17. clang/gcc show that copy/move constructors of base class are not inherited. Can someone provide where it is explained in the standard? Thanks.
The new wording is in [over.match.funcs]/8:
In your example,
B
's inherited copy constructor is excluded from the set of candidates (that constructor has a first parameter of type reference toconst B
, the argument list has exactly one argument -b
, andB
andD
are reference-related).