Skip to content

Instantly share code, notes, and snippets.

@minjang
Last active December 23, 2015 17:02
Show Gist options
  • Save minjang/a5ce4b47fd1c65162850 to your computer and use it in GitHub Desktop.
Save minjang/a5ce4b47fd1c65162850 to your computer and use it in GitHub Desktop.
// 5. 변수를 거치지 않고 직접 사용
cout << "[TEST 5] in-place through rvalue reference\n";
for (auto &&p : enumerate(range(100, 103)))
cout << p.first << ": " << p.second << '\n';
// decltype(p) == pair<size_t, string&>&&
for (auto &&p : enumerate(vector<string>{"foo", "bar", "baz"}))
cout << p.first << ": " << (p.second += p.second) << '\n';
// 함수 반환값 바로 사용
auto create = []()->vector<string> { return {"foo", "bar", "baz"}; };
// decltype(p) == pair<size_t, string&>&&
for (auto &&p : enumerate(create()))
cout << p.first << ": " << p.second << '\n';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment