Boost logo

Boost :

Subject: Re: [boost] [config][mpl][type_traits][integer] BOOST_STATIC_CONSTANT should use constexpr
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-04-22 12:10:23

Le 22/04/13 16:24, Krzysztof Czainski a écrit :
> 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?
You are right, but I was not using an static constant but a static function.


Boost list run by bdawes at, gregod at, cpdaniel at, john at