demux.cpp 623 B

123456789101112131415161718192021222324252627282930
  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/equal.hpp>
  5. #include <boost/hana/functional/demux.hpp>
  6. #include <boost/hana/functional/placeholder.hpp>
  7. #include <boost/hana/tuple.hpp>
  8. namespace hana = boost::hana;
  9. using hana::_;
  10. constexpr auto f = hana::demux(hana::make_tuple)(
  11. _ + _,
  12. _ - _,
  13. _ * _,
  14. _ / _
  15. );
  16. static_assert(
  17. f(10, 4) == hana::make_tuple(
  18. 10 + 4,
  19. 10 - 4,
  20. 10 * 4,
  21. 10 / 4
  22. )
  23. , "");
  24. int main() { }