I understand that RVO enables copy elision of, amongst others, temporaries and local variables, but what about data members ?
To focus the question, which of the following three options is the best way to write a const getter for a data member (given RVO and C++11)?
class Widget { /* some large user-defined class */ };
class C
{
public:
const Widget& getWidget1() const { return w; }
const Widget getWidget2() const { return w; }
Widget getWidget3() const { return w; }
private:
Widget w;
};