//********************************************************
// The following code example is taken from the book
//  C++23 - The Complete Guide
//  by Nicolai M. Josuttis (www.josuttis.com)
//  https://www.cppstd23.com
//
// The code is licensed under a
//  Creative Commons Attribution 4.0 International License
//  https://creativecommons.org/licenses/by/4.0/
//********************************************************


#include <print>
#include <string>
#include <vector>
#include <set>
#include <ranges>
#include <cctype>

int main()
{
  std::vector<std::string> coll{"Kiev", "Tokyo", "LA", "Rome", "Berlin"};
  std::println("coll: {}", coll);

  auto sizeGt2 = [] (const auto& s) { return s.size() > 2; };
  auto toLower = [] (std::string s) {  // by value to have a local copy
                   s[0] = static_cast<char>(std::tolower(s[0])); 
                   return s; 
                 };
  auto v = coll
            | std::views::filter(sizeGt2)           // significant size
            | std::ranges::to<std::multiset>()      // sorted
            | std::views::transform(toLower)        // with lowered first character 
            ;  

  std::println("v:    {}", v);
}

