//******************************************************** // The following code example is taken from the book // C++23 - The Complete Guide // by Nicolai M. Josuttis (www.josuttis.com) // http://www.cppstd23.com // // The code is licensed under a // Creative Commons Attribution 4.0 International License // http://creativecommons.org/licenses/by/4.0/ //******************************************************** #include #include // new view type to process all elements: template struct ProcessView : std::ranges::view_interface> { private: InnerRgT innerRange; // view, ref_view to range, or owning view to range public: template ProcessView(RgT&& rg) : innerRange(std::forward(rg)) { } auto begin() { return innerRange.begin(); } auto end() { return innerRange.end(); } }; // deduction guide to deal with lvalues and rvalues: template ProcessView(RgT&& rg) -> ProcessView>;