====Compatibilité==== ===Conversion d'un range vers un vector=== #include #include #include #include #include inline constexpr auto as_string = [](std::ranges::view auto rng) { auto in = rng | std::views::common; return std::string(in.begin(), in.end()); }; int main() { std::string str = "Now is the time for all good men to come to the aid of their county."; auto rng = str | std::views::split(' ') | std::views::transform(as_string) | std::views::common; std::vector words(rng.begin(), rng.end()); for (std::string s : words) std::cout << s << "-"; } [[https://timur.audio/how-to-make-a-container-from-a-c20-range|How to make a container from a C++20 range]] {{ :lang:cpp:ranges:how_to_make_a_container_from_a_c_20_range_timur.audio_2021-07-03_13_42_12_.html |Archive du 12/02/2020 le 03/07/2021}} [[https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95578|std::ranges::copy and std::views::take_while don't want to play together]] {{ :lang:cpp:ranges:93936_ranges_std_ranges_split_view_..._outeriter_..._current_is_private_within_this_context_2021-07-03_13_43_24_.html |Archive du 25/02/2021 le 03/07/2021}}