mirror of
https://github.com/boostorg/hana.git
synced 2026-02-01 20:42:13 +00:00
This is because using variable templates limits the objects to being constexpr, or to not being constexpr (but then initializing the object becomes an issue). This is also a step towards being compilable by GCC 4.9, but that only would not justify the change.
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
/*
|
|
@copyright Louis Dionne 2014
|
|
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 <boost/hana/assert.hpp>
|
|
#include <boost/hana/ext/std/integral_constant.hpp>
|
|
#include <boost/hana/integral.hpp>
|
|
using namespace boost::hana;
|
|
|
|
|
|
int main() {
|
|
{
|
|
//! [integral_constant]
|
|
BOOST_HANA_CONSTANT_CHECK(
|
|
integral_constant<Integral<int>, 2>()
|
|
==
|
|
int_<2>
|
|
);
|
|
|
|
BOOST_HANA_CONSTANT_CHECK(equal(
|
|
integral_constant<ext::std::IntegralConstant<bool>, true>(),
|
|
std::true_type{}
|
|
));
|
|
//! [integral_constant]
|
|
}
|
|
{
|
|
//! [enumerable]
|
|
BOOST_HANA_CONSTANT_CHECK(
|
|
succ(integral_constant<Integral<int>, 2>())
|
|
==
|
|
integral_constant<Integral<int>, 3>()
|
|
);
|
|
|
|
BOOST_HANA_CONSTANT_CHECK(
|
|
pred(integral_constant<Integral<int>, 2>())
|
|
==
|
|
integral_constant<Integral<int>, 1>()
|
|
);
|
|
//! [enumerable]
|
|
}
|
|
}
|