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