Subject: Re: [boost] [config] BOOST_STATIC_CONSTEXPR in C++11 vs C++14
From: Gary Furnish (gfurnish_at_[hidden])
Date: 2017-08-22 16:18:59
I'd take a look at making something like BOOST_CONSTEXPR_AND_CONST
similarly to BOOST_CONSTEXPR_OR_CONST using BOOST_CXX14_CONSTEXPR.
But I'd name it something like BOOST_COMPILETIME_CONSTANT because
BOOST_CONSTEXPR_AND_CONST would seem to imply always constexpr and
const, which is not what you want. Really though you want to get
other people who are more knowledgeable then I am involved if you want
to add a cross-library macro, so maybe make one for your use case to
On Tue, Aug 22, 2017 at 9:44 AM, Lakshay Garg <lakshayg373_at_[hidden]> wrote:
> 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
>>> 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
>> 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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk