Created on 2015-11-20.00:00:00 last changed 83 months ago
Consider:
struct A
{
A();
A(A&);
explicit A(int);
operator int() const;
};
struct B
{
B(B&& other);
A a;
};
B::B(B&& other) : a(static_cast<B&&>(other).a) {}
// B::B(B&& other) = default; // ill-formed
void f(B& b1)
{
B b2 = static_cast<B&&>(b1);
}
The user-defined move constructor is well-formed because B::a can be initialized via A::operator int() and A::A(int); however, Clang and GCC believe a defaulted one would be ill-formed.
What about the following, which is considered well-formed by compilers and calls A::A(C&&)?
struct C {}; struct A : C { A(); A(A&); A(C&&); }; struct B { B(B&& other); A a; }; B::B(B&& other) = default;
History | |||
---|---|---|---|
Date | User | Action | Args |
2018-02-27 00:00:00 | admin | set | status: open -> drafting |
2015-11-20 00:00:00 | admin | create |