maximum.cpp 814 B

12345678910111213141516171819202122232425
  1. // Copyright Louis Dionne 2013-2017
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
  4. #include <boost/hana/assert.hpp>
  5. #include <boost/hana/equal.hpp>
  6. #include <boost/hana/greater.hpp>
  7. #include <boost/hana/integral_constant.hpp>
  8. #include <boost/hana/maximum.hpp>
  9. #include <boost/hana/tuple.hpp>
  10. namespace hana = boost::hana;
  11. int main() {
  12. // without a predicate
  13. BOOST_HANA_CONSTANT_CHECK(
  14. hana::maximum(hana::tuple_c<int, -1, 0, 2, -4, 6, 9>) == hana::int_c<9>
  15. );
  16. // with a predicate
  17. auto smallest = hana::maximum(hana::tuple_c<int, -1, 0, 2, -4, 6, 9>, [](auto x, auto y) {
  18. return x > y; // order is reversed!
  19. });
  20. BOOST_HANA_CONSTANT_CHECK(smallest == hana::int_c<-4>);
  21. }