In the release notes of the latest Visual Studio update (15.7), Microsoft states (9th bullet point):
Inheriting a constructor now works the same as inheriting any other base class member. Previously, this worked by declaring a new constructor that delegates to the original; with this change, base class constructors are visible in a derived class as if they were derived class constructors, improving consistency in C++.
I'm slightly confused what that point actually means.
AFAIK, constructor inheritance requires an explicit using BaseClass::BaseClass;
(since C++11):
struct Base
{
Base() = default;
Base(int x) : x(x) {}
int x;
};
struct Derivative : Base
{
using Base::Base;
Derivative(int x, int y) : Base(x), y(y) {}
int y;
};
void main()
{
Derivative x(10); // this is ok
}
My understanding of the quote is, that MS allows the constructor inheritance without the need of using BaseClass::BaseClass;
. But testing the following code after applying the update doesn't seem to change anything in those regards:
struct Base
{
Base() = default;
Base(int x) : x(x) {}
int x;
};
struct Derivative : Base
{
int y{};
};
void main()
{
Derivative x(10); // still illegal, compiler error
}
My questions are:
- What does the quote actually mean? What changed?
- How does this improve consistency in C++ (AFAIK, the standard didn't change anything in terms of ctor inheritance)?