compile.hana.map.erb.cpp 785 B

1234567891011121314151617181920212223242526272829
  1. // Copyright Jason Rice 2015
  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/bool.hpp>
  5. #include <boost/hana/find_if.hpp>
  6. #include <boost/hana/integral_constant.hpp>
  7. #include <boost/hana/map.hpp>
  8. namespace hana = boost::hana;
  9. struct is_last {
  10. template <typename N>
  11. constexpr auto operator()(N) const {
  12. return hana::bool_c<N::value == <%= input_size %>>;
  13. }
  14. };
  15. struct undefined {};
  16. int main() {
  17. constexpr auto map = hana::make_map(
  18. <%= (1..input_size).map { |n|
  19. "hana::make_pair(hana::int_c<#{n}>, undefined{})"
  20. }.join(', ') %>
  21. );
  22. constexpr auto result = hana::find_if(map, is_last{});
  23. (void)result;
  24. }