boost::hana::IntegralConstant< C > Struct Template Reference

struct boost::hana::IntegralConstant< C >

The `IntegralConstant`

concept represents compile-time integral values.

The `IntegralConstant`

concept represents objects that hold a `constexpr`

value of an integral type. In other words, it describes the essential functionality provided by `std::integral_constant`

. An `IntegralConstant`

is also just a special kind of `Constant`

whose inner value is of an integral type.

The requirements for being an `IntegralConstant`

are quite simple. First, an `IntegralConstant`

`C`

must be a `Constant`

such that `Tag::value_type`

is an integral type, where `Tag`

is the tag of `C`

.

Secondly, `C`

must have a nested `static constexpr`

member named `value`

, such that the following code is valid:

constexpr auto v = C::value;

Because of the requirement that `Tag::value_type`

be an integral type, it follows that `C::value`

must be an integral value.

Finally, it is necessary to specialize the `IntegralConstant`

template in the `boost::hana`

namespace to tell Hana that a type is a model of `IntegralConstant`

:

namespace boost { namespace hana {

template <>

struct IntegralConstant<your_custom_tag> {

};

}}

`Constant`

(free implementation of`value`

)

The`value`

function required to be a`Constant`

can be implemented as follows for`IntegralConstant`

s:Thevalue<C>() == C::value`to`

function must still be provided explicitly for the model of`Constant`

to be complete.

constexpr auto value

Return the compile-time value associated to a constant.