infix.cpp 651 B

1234567891011121314151617181920
  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/config.hpp>
  6. #include <boost/hana/equal.hpp>
  7. #include <boost/hana/functional/infix.hpp>
  8. #include <boost/hana/pair.hpp>
  9. namespace hana = boost::hana;
  10. BOOST_HANA_CONSTEXPR_LAMBDA auto divmod = hana::infix([](auto x, auto y) {
  11. // this could be a more efficient implementation
  12. return hana::make_pair(x / y, x % y);
  13. });
  14. int main() {
  15. BOOST_HANA_CONSTEXPR_CHECK((42 ^divmod^ 23) == hana::make_pair(1, 19));
  16. }