On Wed, 13 May 2020 at 12:37, Marco Bubke <[email protected]> wrote: > auto view3 = myObject.getCopy()[42].getView(); // not safe, copy is destroyed > AFAIK you can say that a rvalue should not return a reference by using > ref-qualified member functions. > View getView() const & { return v;}
However, whatever_function(myObject.getCopy()[42].getView()); // never dangles, so always safe Disabling reference returns for rvalues prevents such forwarding cases from working, and you need to declare a separate lvalue to make your code work. _______________________________________________ Development mailing list [email protected] https://lists.qt-project.org/listinfo/development
