Boost logo

Boost :

Subject: Re: [boost] [config] consexpr workaround
From: John Maddock (boost.regex_at_[hidden])
Date: 2010-11-13 04:40:31


>in order to make easier the introduction of constexpr in a portable way I
>would like we add a Boost Config workarround. We can define
>some macros depending on whether BOOST_NO_CONSTEXPR is defined or not.

#if defined(BOOST_NO_CONSTEXPR)
#define BOOST_CONSTEXPR
#define BOOST_CONSTEXPR_OR_CONST const
#else
#define BOOST_CONSTEXPR constexpr
#define BOOST_CONSTEXPR_OR_CONST constexpr
#endif

OK

>We could also add a STATIC_CONSTEXPR macro
>
>#define BOOST_STATIC_CONSTEXPR static BOOST_CONSTEXPR_OR_CONST
>
>
>For this case the existing macro BOOST_STATIC_CONSTANT could be modified to
>use BOOST_CONSTEXPR_OR_CONST when static const was used.

I don't see how that can work:

* If the type being initialized is known to be an integer type then we can
use BOOST_STATIC_CONSTANT and we wouldn't gain anything from using constexp?
* If the type being initialized might not be an integer type, then we can
use constexp or a static const declaration, but we can't use
BOOST_STATIC_CONSTANT (because it may be implemented in terms of an enum).

Other than that, care to provide a patch?

Cheers, John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk