C++ universal reference in constructor and return value optimization (rvo)
Why does rvalue optimization not occur in classes with constructor with universal reference arguments? http://coliru.stacked-crooked.com/a/672f10c129fe29a0 #include <iostream> template<class ...ArgsIn> struct C { template<class ...Args> C(Args&& ... args) {std::cout << "Ctr\n";} // rvo occurs without && ~C(){std::cout << "Dstr\n";} }; template<class ...Args> auto f(Args ... args) { int i = 1; return C<>(i, i, i); } int main() { auto obj = f(); } Output: Ctr Ctr Dstr Ctr Dstr Dstr I believe that the problem is that instantiations of template<class ...Args> C(Args&& ... args) {std::cout << "Ctr