BB
x++;
return x;
}
rror: cannot bind rvalue reference of type ‘int&&’ to lvalue of type ‘int’ in 'return x;'
Size: a a a
BB
hh
D
hh
D
hh
hh
hh
D
struct S {
std::string str
S(std::string&& str) : str(str) {} // copy
S(std::string&& str) : str(std::move(str)) {} // move
};
D
x
— это lvalue выражение типа r-value ссылка на int
hh
ПК
D
const&
в некоторых случаях продлевают жизни временных объектовhh
hh
ПК
ПК
ПК
hh
hh