• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright Louis Dionne 2013-2017
2 // Copyright Jason Rice 2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
5 
6 #include <boost/hana/index_if.hpp>
7 #include <boost/hana/integral_constant.hpp>
8 
9 #include <cstddef>
10 #include <support/counter.hpp>
11 
12 namespace hana = boost::hana;
13 
14 
main()15 int main() {
16     // Tests hana::index_if on an infinite iterable
17     constexpr Counter<> c{};
18     auto pred = [](auto i) {
19         return [=](auto x) {
20             return hana::bool_c<decltype(x)::value == decltype(i)::value>;
21         };
22     };
23 
24     static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<0>)).value()){}) == 0, "");
25     static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<1>)).value()){}) == 1, "");
26     static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<2>)).value()){}) == 2, "");
27     static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<3>)).value()){}) == 3, "");
28     static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<4>)).value()){}) == 4, "");
29     static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<5>)).value()){}) == 5, "");
30     static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<6>)).value()){}) == 6, "");
31 }
32