Код: Выделить всё
struct Foo {};
Foo meh() {
return std::move(Foo());
}
Но что в подобных случаях?
Код: Выделить всё
struct Foo {};
Foo meh() {
Foo foo;
//do something, but knowing that foo can safely be disposed of
//but does the compiler necessarily know it?
//we may have references/pointers to foo. how could the compiler know?
return std::move(foo); //so here the move is needed, right?
}
Подробнее здесь: https://stackoverflow.com/questions/148 ... turn-value
Мобильная версия