On Wed, Mar 25, 2015 at 11:38 AM, John Maddock <jz.maddock@googlemail.com> wrote:


On 25/03/2015 14:58, Raffi Enficiaud wrote:
Hi,

I have a test that should compile the code with C++11 options. For eg. GCC, I have a rule like this, which I do not like

<toolset>gcc-4.4:<cxxflags>-std=c++0x
<toolset>gcc-4.5:<cxxflags>-std=c++0x
<toolset>gcc-4.6:<cxxflags>-std=c++0x
<toolset>gcc-4.7:<cxxflags>-std=c++11

I would like to know:
- if there is a better way to do this
- if it is possible to set the option "-std=c++11" for compilers with versions >= 4.7

I don't think we have a toolset option for that - though it sure would be useful!

The way I do it, is not to second guess / change what options the test runner is using, but either:

* Make the test a no-op if the C++11 features used aren't present, or:
* Use the Boost.Config build checks to disable the test altogether if the features you require aren't available (http://www.boost.org/doc/libs/1_57_0/libs/config/doc/html/boost_config/build_config.html).

The point of doing things this way, is it "works" for compilers other than GCC, including those that don't have switches to select the language dialect (ie the features either work or they don't).

+1

But.. I would highly recommend that you do both of the above. The first one makes it so that someone not using BB can make use of the test (for whatever reason they like). And the second one removes it from the test results table so that it reduces the noise.

But if that is not what you are after you can also use the Boost Predef checks to set those options. As they support more than just a specific compiler version. See the docs for how to use that here <https://rawgit.com/boostorg/predef/develop/doc/html/predef/check_utilities.html>.


--
-- Rene Rivera
-- Grafik - Don't Assume Anything
-- Robot Dreams - http://robot-dreams.net
-- rrivera/acm.org (msn) - grafikrobot/aim,yahoo,skype,efnet,gmail