Subject: Re: [boost] C++03 / C++11 compatibility question for compiled libraries
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2018-02-09 19:08:16
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?
> 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.
- 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.
For Boost.Test my overall recommendation is:
always use boost::function, but use std::bind
when it is available.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk