//********************************************************
// 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 <vector>
#include <functional>
#include <ranges>

int main()
{
  std::vector coll{47, 11, 0, 8, 15, -11, 7, 42, 99};
  std::println("coll: {}", coll);

  // store all odd values negated in a new container:
  auto isOdd = [] (auto val) { return val % 2 != 0; };
  std::vector<int> vec = coll | std::views::filter(isOdd)
                              | std::views::transform(std::negate{})
                              | std::ranges::to<std::vector<int>>();

  // print the container:
  std::println("vec:  {}", vec);
}

