Skip to content

Instantly share code, notes, and snippets.

@h-sao
Created July 12, 2017 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h-sao/8bc25ff069ff695e709c660622f18fec to your computer and use it in GitHub Desktop.
Save h-sao/8bc25ff069ff695e709c660622f18fec to your computer and use it in GitHub Desktop.
Rvalue/Lvalue
struct Foo{
using Type = std::vector<Bar>
// 1 Lvalue
Type & data() & { return data_; }
// 2 Rvalue
Type data() && { return std::move ( data_ ); }
Type data_;
}
Foo makeFoo();
auto v = makeFoo().data();
auto v = std::move( makeFoo().data());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment