|
Boost : |
Subject: [boost] [config] BOOST_STATIC_CONSTEXPR in C++11 vs C++14
From: Lakshay Garg (lakshayg373_at_[hidden])
Date: 2017-08-22 11:28:32
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk