cplusplus / draft

C++ standards drafts
http://www.open-std.org/jtc1/sc22/wg21/
5.69k stars 751 forks source link

[ranges] Fix examples that want to be inside a function body #3105

Open jensmaurer opened 5 years ago

jensmaurer commented 5 years ago

Wrap inside a function.

Example:

auto ints = view::iota(0) | view::take(10);
auto latter_half = drop_view{ints, 5};
for (auto i : latter_half) {
  cout << i << ' ';                             // prints 5 6 7 8 9
}
jensmaurer commented 5 years ago

Editorial teleconference: Strive to put all examples into functions that need to be, as a general policy. Except where it would distract from the readability of the example.