For instance:
Big create() { Big x; return std::move(x); // return static_cast<typename std::remove_reference<T>::type&&>(t) // why not elide here? }
Assuming that applying std::move()to return a local variable prohibits movement-semantics, because compilers cannot make any assumptions about the internal functions of functions in general, with regard to cases where these assumptions are not needed, for example, when:
std::move()
std::move(x)
static_cast<typename std::remove_reference<T>::type&&>(t)
In accordance with the current standard, implementations are allowed to apply NRVO ...
- return , - ( , - (18.3)) ( cv-qualification) , /
, 1), 2) . , std::move() , ?
-. " std::move() (N) RVO '
, , .
return , - ( , - (18.3)) ( cv-qualification)
NRVO , , std::move(), , std::move X, X&&. !
std::move
X
X&&
, " ". , , , " ". , , , , . , , , , .
, ? , , (, , ), , . , , (, string), , , , ( ) ( , , ).
string
, , . , . , . , , , , , .
: , ? . , , .
Source: https://habr.com/ru/post/1683189/More articles:navbar not rendering in browser using ng-bootstrap & angular 4 - angularBridge Bridge Polymorphic Types - haskellEfficient way to manage javascript / coffeescript code for Rails 5? - javascriptJavaScript `for in` returns sorted elements - javascriptHow to specify a row with a click in the table - androidCreate YouTube playlist with NodeJS - javascriptPlay local mp4 file in electronic - html5-videoMicrosoft Graph Web Host Missing ClientState - microsoft-graphUsing values ββfrom `__m256i` for efficient array access - SIMD - c ++What is the alternative to legacy .ix for label-based mixed selection? - pythonAll Articles