]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/assert/constant.cpp
1 // Copyright Louis Dionne 2013-2016
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>
7 #include <support/cnumeric.hpp>
8 namespace hana
= boost::hana
;
12 auto constant_bool() { return make_cnumeric
<bool, value
>(); }
15 constexpr auto constexpr_constant_bool() { return make_cnumeric
<bool, value
>(); }
18 // Make sure it works at global scope
19 BOOST_HANA_CONSTANT_ASSERT(constant_bool
<true>());
20 BOOST_HANA_CONSTANT_ASSERT_MSG(constant_bool
<true>(), "message");
22 // Make sure it works at namespace scope
24 BOOST_HANA_CONSTANT_ASSERT(constant_bool
<true>());
25 BOOST_HANA_CONSTANT_ASSERT_MSG(constant_bool
<true>(), "message");
28 // Make sure it works in a constexpr context
29 constexpr bool constexpr_context() {
30 BOOST_HANA_CONSTANT_ASSERT(constexpr_constant_bool
<true>());
31 BOOST_HANA_CONSTANT_ASSERT_MSG(constexpr_constant_bool
<true>(), "message");
34 static_assert(constexpr_context(), "");
38 // Make sure it works at function scope
39 BOOST_HANA_CONSTANT_ASSERT(constant_bool
<true>());
40 BOOST_HANA_CONSTANT_ASSERT_MSG(constant_bool
<true>(), "message");
42 // Make sure it works inside a lambda
44 BOOST_HANA_CONSTANT_ASSERT(constant_bool
<true>());
45 BOOST_HANA_CONSTANT_ASSERT_MSG(constant_bool
<true>(), "message");
49 // Make sure we can reference a local variable
50 auto yes
= constant_bool
<true>();
51 BOOST_HANA_CONSTANT_ASSERT(yes
);
52 BOOST_HANA_CONSTANT_ASSERT_MSG(yes
, "message");