I was surprised to see that this compiles in C++20 (GCC):
#include <iostream>
struct Test {
int a;
int b;
};
void main() {
Test myTest(1, 2);
std::cout << myTest.b; // 2
}
Changing struct
to class
or switching to C++17 throws the error I expected:
error: no matching function call to 'Test::Test(int, int)'
I tried googling, but could not find anything relevant. In C++20, is there a new kind of compiler-generated constructor for structs?