Consider the following snippet:
class Bar {...};
class Foo {
public:
Foo(const Bar& bar): bar_(bar) {}
private:
Bar bar_;
};
int main() {
Foo foo({...}); // Passing an rvalue Bar object here.
}
Question: will the object that I have generated be copied in the Foo's constructor, or will it be moved? More precisely, which of the following is true?
- It will be copied always.
- It will be moved always (I'm pretty sure it is not the case).
- This is unspecified behavior.