|
Boost : |
Subject: Re: [boost] [config] BOOST_STATIC_CONSTEXPR in C++11 vs C++14
From: Lakshay Garg (lakshayg373_at_[hidden])
Date: 2017-08-22 15:44:52
On 22 August 2017 at 20:12, Gary Furnish via Boost
<boost_at_[hidden]> wrote:
> On Tue, Aug 22, 2017 at 5:28 AM, Lakshay Garg via Boost
> <boost_at_[hidden]> wrote:
>> This conversation is in reference to
>> https://github.com/boostorg/math/pull/82 but I'm posting it here
>> because it might be of interest to some.
>>
>> On 22 August 2017 at 13:53, jzmaddock <notifications_at_[hidden]> wrote:
>>> Note that those changes don't actually make the functions constexpr - or
>>> indeed change the way the constants are initialized - in fact in C++14
>>> BOOST_STATIC_CONSTEXPR doesn't even imply the constants are "const
>>> (C++11 is different, and early implementations prevent you from writing
>>> "constexpr const" which is what C++14 permits).
>>
>> Since BOOST_STATIC_CONSTEXPR behaves differently in C++11 and 14,
>> would it be a good idea for boost.config to provide a macro for
>> handling the `static const var = ...;` kind of variable
>> initializations in a portable manner? Maybe something like
>> BOOST_COMPILETIME_CONSTANT?
>>
>> Such a macro might will be useful for declarations where we want the
>> variable to be a constant in all possible senses (compile-time,
>> run-time) and allow generating the most optimal code possible with the
>> language version, compiler being used in a portable manner.
>>
>> An example of the kind of constants I am talking about can be seen
>> here: https://github.com/boostorg/math/blob/develop/include/boost/math/special_functions/prime.hpp#L40
>>
>> Lakshay
>>
>>
> This seems like a reasonable idea.
Since I am just getting started with boost, I don't have much idea on
how to go about doing this. It would be very helpful is people can
post in their suggestions/reference material so I can look at it and
write such a macro.
Lakshay
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk