Why doesn't C ++ use RVO when returning local std :: stringstream?

I read a lot of information about rvalue and returned local variables in C ++> = 11. From what I understood, is that "just return by value, do not use move / forward and do not add a signature to the && to method, and the compiler optimizes it for you. "

Ok, I want this to happen:

#include <sstream>

std::stringstream GetStream() {
    std::stringstream s("test");
    return s;
}

auto main() -> int {
    auto s = GetStream();
}

I get nice

error: use of deleted functionstd::basic_stringstream<char>::basic_stringstream(const std::basic_stringstream<char>&)’
     return s;

error. I do not understand why he is trying to create a copy constructor? Doesn't he use a move constructor with all the good things from C ++ 11 here? I use "-std = C ++ 14".

+4
source share
1 answer

All Articles