on.cpp 606 B

1234567891011121314151617181920212223242526
  1. // Range v3 library
  2. //
  3. // Copyright Eric Niebler 2020
  4. //
  5. // Use, modification and distribution is subject to the
  6. // Boost Software License, Version 1.0. (See accompanying
  7. // file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // Project home: https://github.com/ericniebler/range-v3
  11. #include <range/v3/functional/on.hpp>
  12. #include <range/v3/functional/concepts.hpp>
  13. #include "../simple_test.hpp"
  14. using namespace ranges;
  15. int square(int i) { return i * i; }
  16. int main()
  17. {
  18. auto fn = on(std::multiplies<>{}, square);
  19. CHECK(fn(2, 4) == 64);
  20. return ::test_result();
  21. }