compile.std.integer_sequence.erb.cpp 745 B

123456789101112131415161718192021222324252627
  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/bool.hpp>
  5. #include <boost/hana/ext/std/integer_sequence.hpp>
  6. #include <boost/hana/find_if.hpp>
  7. #include <boost/hana/integral_constant.hpp>
  8. #include <utility>
  9. namespace hana = boost::hana;
  10. struct is_last {
  11. template <typename N>
  12. constexpr auto operator()(N) const {
  13. return hana::bool_c<N::value == <%= input_size %>>;
  14. }
  15. };
  16. int main() {
  17. auto sequence = std::integer_sequence<
  18. <%= (["int"] + (1..input_size).to_a).join(', ') %>
  19. >{};
  20. auto result = hana::find_if(sequence, is_last{});
  21. (void)result;
  22. }