c++ - C++11 rvalue reference questions -
i trying understand new features of c++11, , have 2 questions regarding rvalue references.
i have not seen examples when functions homecoming rvalue references (except std::move
). there cases when makes sense so? e. g., int&& foo(...)
.
are there cases when makes sense have rvalue references const, either when declaring local variables or function arguments? e. g., foo(int const&& i)
.
1) have not seen examples when functions homecoming rvalue references (except std::move
). there cases when makes sense so?
apart library functions not doing much more casting argument rvalue reference (such std::move
and, when appropriate, std::forward
) , returning argument, don't believe meet often.
2) there cases when makes sense have rvalue references const
?
not many. none, actually. rvalue references used when want bind object want move from, , since cannot move const
object (because moving alters state of object move from, , const
promises opposite), makes little sense have rvalue reference const
. notice, lvalue references const
can bind rvalues well. there a few utilize cases that though.
c++ c++11 reference rvalue-reference
No comments:
Post a Comment