I perform following statements in MSVC with /std:c++17 successfully without any compile error.
class A {
public:
A() {
std::cout << "default constructor." << std::endl;
}
A(const A&) {
std::cout << "const A&" << std::endl;
}
A(A&&) {
std::cout << "A&&" << std::endl;
}
int a;
};
A& a = A();
auto& b = A();
I can't believe that a lvalue reference can be initialized with a rvalue, as well as for auto&.
But I have tested with some online compiler and they issued compile error expectedly.
I really want to know what's the underlying reason of the distinction between MSVC with online compiler.
Any reply is very much appreciated!