]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/repeat.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/assert.hpp>
6 #include <boost/hana/fwd/concept/integral_constant.hpp>
7 #include <boost/hana/repeat.hpp>
8 namespace hana
= boost::hana
;
11 //////////////////////////////////////////////////////////////////////////////
12 // Define a simple model of IntegralConstant for use below
15 static constexpr int value
= i
;
16 using value_type
= int;
19 namespace boost
{ namespace hana
{
21 struct IntegralConstant
<constant
<i
>> {
22 static constexpr bool value
= true;
25 // definition of `to<>` omitted
27 //////////////////////////////////////////////////////////////////////////////
33 hana::repeat(constant
<3>{}, [&] { ++counter
; });
34 BOOST_HANA_RUNTIME_CHECK(counter
== 3);
36 // Try with a normal function.
37 hana::repeat(constant
<3>{}, function
);
39 // Try with a function pointer.
40 hana::repeat(constant
<3>{}, static_cast<void(*)()>(function
));
42 // Make sure we don't read from a non-constexpr variable.
44 hana::repeat(three
, []{});