Boost logo

Boost :

Subject: Re: [boost] [Config] Support for switching between std::andboost::equivalents.
From: Edward Diener (eldiener_at_[hidden])
Date: 2015-06-07 11:53:35


On 6/7/2015 6:41 AM, Peter Dimov wrote:
> Edward Diener wrote:
>> I design a library which, let's say, takes a regex object as parameter
>> to some exported function. If the end-user of my library is compiling
>> in C++11 mode is it more likely that his use of regex will be
>> std::regex or boost::regex ? IMO it is the former. Conversely if the
>> end-user of my library is compiling in C++03 mode is it more likely
>> that his use of regex will be std::regex or boost::regex ? That's a
>> loaded question of course because std::regex won't be available to him
>> if he compiles in C++03 mode. So my preferred usage of regex in my
>> library, all else being equal, is to use boost::regex in C++03 mode
>> and std::regex in C++11 mode.
>
> This makes sense, and the question of dependencies and modular
> distributions is actually a side show.
>
> But you do realize that you'll be breaking your customer's C++03
> (presumably tried and tested) code the moment he adds -std=c++11 in
> order to use a for(:) loop, right?

Not if they use the macro system I propose in their own code to choose
between Boost or C++ standard library equivalents. Or at least use the
macro system I propose when interfacing with my library. Although for
consistency's sake it would be easier to use the macro system in all
places in their module, if they choose to not use it when not
interfacing with my library that is their business.

Breaking code when switching between C++03 mode and C++11 mode can occur
outside the macro system I propose easily enough. Someone writes their
code to use std::regex and compile in C++11 mode. They then switch to
C++03 mode. Is std::regex still available in C++03 mode ? If it is not
they have broken their code. It's not as if switching compile modes is
as easy people suggest. A number of considerations have to be taken into
account.


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