I'd take a look at making something like BOOST_CONSTEXPR_AND_CONST
similarly to BOOST_CONSTEXPR_OR_CONST using BOOST_CXX14_CONSTEXPR.
See http://www.boost.org/doc/libs/1_65_0/libs/config/doc/html/boost_config/boost...
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
test it.
On Tue, Aug 22, 2017 at 9:44 AM, Lakshay Garg
On 22 August 2017 at 20:12, Gary Furnish via Boost
wrote: On Tue, Aug 22, 2017 at 5:28 AM, Lakshay Garg via Boost
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
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_fun...
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