// Copyright Louis Dionne 2013-2017 // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include #include #include #include #include namespace hana = boost::hana; // A simple infinite Iterable. template struct counter { }; namespace boost { namespace hana { template struct at_impl> { template static constexpr auto apply(counter, N const&) { return hana::int_c; } }; template struct drop_front_impl> { template static constexpr auto apply(counter, N) { return counter{}; } }; template struct is_empty_impl> { static constexpr auto apply(counter) { return hana::false_c; } }; }} int main() { // find_if and any_of should short-circuit and stop even though the // Iterable is infinite. BOOST_HANA_CONSTANT_CHECK(hana::any_of(counter<1>{}, hana::equal.to(hana::int_c<4>))); BOOST_HANA_CONSTANT_CHECK(hana::equal( hana::find_if(counter<1>{}, hana::equal.to(hana::int_c<4>)), hana::just(hana::int_c<4>) )); }