Not sure whether Section 12.8 #31.3
[...] copy elision, is permitted in the following circumstances (which
may be combined to eliminate multiple copies):
when a temporary class object that has not been bound to a reference
([class.temporary]) would be copied/moved to a class object with the
same cv-unqualified type, the copy/move operation can be omitted by
constructing the temporary object directly into the target of the
omitted copy/move [...]
applies to following:
class A {
public:
A() {}
A(const A&) = delete;
A(A&&) { printf("move"); }
};
void foo(A a) {}
int main() {
A a;
foo(std::move(a));
}
Is elision allowed in this case? I want to ensure a
is moved from.
question from:
https://stackoverflow.com/questions/65910443/copy-move-constructor-elision 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…