The following code example is taken from the book
C++23 - The Complete Guide
by Nicolai M. Josuttis,
Leanpub, 2026
The code is licensed under a
Creative Commons Attribution 4.0 International License.
// raw code
#include <print>
#include <vector>
#include <list>
#include <set>
#include <ranges>
int main()
{
std::list data{47, 11, 42, 0, 8, 15};
std::vector coll1{std::from_range, data};
std::println("coll1: {}", coll1);
std::set coll2{std::from_range, data};
std::println("coll2: {}", coll2);
std::vector coll3{std::from_range, std::views::iota(1, 11)};
std::println("coll3: {}", coll3);
}