Boost logo

Boost :

Subject: Re: [boost] [Config] Support for switching between std:: and boost:: equivalents.
From: Edward Diener (eldiener_at_[hidden])
Date: 2015-06-05 10:42:50


On 6/5/2015 10:00 AM, Rob Stewart wrote:
> On June 5, 2015 5:30:03 AM EDT, Edward Diener <eldiener_at_[hidden]> wrote:
>> On 6/5/2015 3:41 AM, John Maddock wrote:
>>> There is a pull-request for Config to provide support for switching
>>> between boost:: and std:: library equivalents:
>>> https://github.com/boostorg/config/pull/63
>>>
>>> My questions are:
>>>
>>> * Is this the right approach? And,
>>> * Is Boost.Config the right place for it?
>>
>> I don't know what "the right approach" would be but this is one
>> approach that does work easily.
>
> It does seem like a reasonable approach overall. It's relatively simple and doesn't try to hide much.
>
> I can't think of a better place for this than Config.
>
>> It is very easy to use. For library 'XXX':
>>
>> 1) Just include the particular Boost.config header provided for a
>> particular interoperable library XXX:
>>
>> #include <boost/config/cpp/XXX.hpp>
>
> I noticed in your PR that you also provide a header to get all such headers at once. I wonder whether the individual headers are really that useful. You could keep the implementation you have, but just document the one header.

The one header is documented. I have the individual headers to avoid
flooding the macro namespaces with lots of macros you are not going to use.

>
>> 2) Include that library's main header file using the macro provided
>> for that library:
>>
>> #include BOOST_CPP_XXX_HDR
>
> Why do you have "CPP" in that name? BOOST_XXX_HDR would seem sufficient. I also would suggest using HEADER rather than HDR.

I like to avoid macro name clashes, Having a common prefix, such as CPP,
tends to do that.

As far as the more verbose HEADER instead of the shorter HDR that's fine
with me if others like that instead. I could even change
BOOST_CPP_XXX_NS to BOOST_CPP_XXX_NAMESPACE and have everybody type out
the fully explicit names.

>
>> 3) In code for that library's functionality use the namespace macro
>> provided for accessing the library's functionality:
>> BOOST_CPP_XXX_NS::some_functionality etc.
>
> Why do you have "CPP" in that name? BOOST_XXX_NS would seem sufficient.
>
>> If you need to do anything different depending on whether you are
>> using
>> the C++ standard version of the library or the Boost version of the
>> library you can test the BOOST_CPP_HAS_XXX macro, which is 1 for the
>> C++
>> standard version existing in the compiler implementation and is 0 for
>> only the Boost version existing in the compiler implementation.
>
> That macro would seem better named, BOOST_HAS_STD_XXX our BOOST_XXX_IS_STD. (The latter is more consistent with my earlier suggestions.)

Again I like distinct macro names so BOOST_CPP_something seems right,
but your other suggestions, as BOOST_CPP_HAS_STD_XXX or
BOOST_CPP_XXX_IS_STD, are fine. Please realize that all macros are in a
global namespace with everything and avoiding macro name clashes in any
TU is of paramount importance.


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