Boost logo

Boost :

Subject: Re: [boost] C++03 / C++11 compatibility question for compiled libraries
From: Raffi Enficiaud (raffi.enficiaud_at_[hidden])
Date: 2018-02-10 10:32:18


Le 09.02.18 à 20:08, Steven Watanabe via Boost a écrit :
> AMDG
>
> On 02/09/2018 11:45 AM, John Maddock via Boost wrote:
>>
>>
>> On 08/02/2018 08:50, Raffi Enficiaud via Boost wrote:
>>> Dear list,
>>>
>>> I have a technical question I do not know how to address, and I would
>>> like to know how people deal with this.
>>>
>>> To put things in the background: boost.test uses heavily boost::function
>>> and boost::bind, however I would like to use in some circumstances
>>> std::function and std::bind, which are, for instance, variadic.
>>
>> Trying to get back to the case in point... is there any reason not to
>> support both in the binary library?
>>
>> ie
>>
>> virtual int operator()( boost::function<int ()> const& F ) = 0;
>> virtual int operator()( std::function<int ()> const& F ) = 0;
>>
>> One of these can presumably simply call the other internally since a
>> boost::function should be storable in a std::function and vice versa?
>>
>
> In this particular case, there shouldn't be any need
> to provide both explicitly as boost::function and
> std::function are convertible to each other.
>
> In general, I think that:
> - interfaces that take boost/std::xxx as a parameter
> should accept both.> - interfaces that return boost/std::xxx are hard
> and I don't know how to handle them.

Yes. You are starting/proposing a recipe for ABI compatibility, which is
the target of my concerns. Now:

* do you think we can elaborate more on this? For instance, same type of
problem should apply to template parameters as well, exceptions, new
keywords...
* do you think we can set up mechanisms that checks we are doing it
right? (apart from trial and error, which has an exponential complexity
in the number of types). I am just unaware of any tool or methodology
that may help me doing it right.

> - The internal implementation can pick one or the
> other. If you want ABI compatibility between C++03
> and C++11, and the object crosses an ABI boundary,
> that means always using boost::xxx.

I was hoping for another solution ... To me, that means that long run,
boost is implementing a side, non-compatible, C++ standard.

>
> For Boost.Test my overall recommendation is:
> always use boost::function, but use std::bind
> when it is available.
>

The little story behind boost::bind was that, I believe around ~1.60, I
encountered issues between std::bind and boost::function for moveable
parameters. Maybe I was doing it wrong at that time, now it seems to be
fixed (I tested). But I think the problem remains.

> In Christ,
> Steven Watanabe
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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