|
Boost : |
Subject: Re: [boost] [config][mpl][type_traits][integer] BOOST_STATIC_CONSTANT should use constexpr
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2013-04-22 10:24:42
2013/4/22 Vicente J. Botet Escriba <vicente.botet_at_[hidden]>
> Out of curiosity, can you detect the difference? What can you do with
>> constexpr values that you can't with static const ones?
>>
>> Even if most of the uses of integral_constant is to use its member
> ::value integral constant defines also the operator(), so it is a nullary
> functor.
>
> integral_constant<int, 1> a;
> constexpr int f();
>
> template <int I>
> void g();
>
> template <typename F>
> void h(F&& fct) { g<fct()>(); }
> h(&f);
> h(a);
>
> The last sentence will not compile if the operator() is not a constexpr
> and it can not be a constexpr if ::value is not a consexpr, or can it?
>
Really?? I thought a static constant can be used in constexpr functions,
just like in C++03 it could be used as a non-type template parameter or
static array size. Am I wrong here?
Regards,
Kris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk