]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/issues/github_31.cpp
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)
5 #include <boost/hana/any_of.hpp>
6 #include <boost/hana/assert.hpp>
7 #include <boost/hana/bool.hpp>
8 #include <boost/hana/equal.hpp>
9 #include <boost/hana/find_if.hpp>
10 #include <boost/hana/fwd/at.hpp>
11 #include <boost/hana/fwd/drop_front.hpp>
12 #include <boost/hana/fwd/is_empty.hpp>
13 #include <boost/hana/integral_constant.hpp>
14 #include <boost/hana/optional.hpp>
15 namespace hana
= boost::hana
;
18 // A simple infinite Iterable.
22 namespace boost
{ namespace hana
{
24 struct at_impl
<counter
<i
>> {
26 static constexpr auto apply(counter
<i
>, N
const&) {
27 return hana::int_c
<i
+ N::value
>;
32 struct drop_front_impl
<counter
<i
>> {
34 static constexpr auto apply(counter
<i
>, N
) { return counter
<i
+ N::value
>{}; }
38 struct is_empty_impl
<counter
<i
>> {
39 static constexpr auto apply(counter
<i
>) { return hana::false_c
; }
45 // find_if and any_of should short-circuit and stop even though the
46 // Iterable is infinite.
47 BOOST_HANA_CONSTANT_CHECK(hana::any_of(counter
<1>{}, hana::equal
.to(hana::int_c
<4>)));
49 BOOST_HANA_CONSTANT_CHECK(hana::equal(
50 hana::find_if(counter
<1>{}, hana::equal
.to(hana::int_c
<4>)),
51 hana::just(hana::int_c
<4>)