c++11 - Using std::move, and preventing further use of the data -
i have been using c++11 time avoided using std::move because scared that, while reading library user not have access code, try use variable after move it.
so like
void loaddata(std::string&& path);
would not enough make user understand moved. expected use of && imply data moved. know comments can used explain use case, lot of people dont pay attention that.
is safe assume when see && data moved, or when should use std::move , how make explicit signature.
is expected use of && imply data moved.
generally speaking yes. user cannot call loaddata
lvalue. must provide prvalue or xvalue. if have variable pass, code loaddata(std::move(variable))
, pretty indicator of you're doing side. forward
ing employed, you'd still see @ call site.
indeed, speaking extremely rude move parameter not rvalue reference.
Comments
Post a Comment