Boost logo

Boost :

Subject: Re: [boost] [function] Bind to std::function if supported?
From: Andrew Ho (helloworld922_at_[hidden])
Date: 2013-07-09 14:49:58


> std::atomic is also slightly different from boost::atomic (or rather,
> std::atomic_flag from boost::atomic_flag).

>From the boost::atomic documentation:

> It implements the interface as defined by the C++11 standard, but makes
this feature available for platforms lacking system/compiler support for
this particular C++11 feature.

If the interface it actually implements is different, perhaps
boost::atomic's interface needs to change? I can't seem to find
documentation for boost::atomic_flag (at least in the official online docs),
either.

Similarly, should we make such changes to boost::function/boost::bind?

It does seem like changes at least to boost::function and most likely
boost::bind would likely break old code, but I kind of view these libraries
as "providing std library support for compilers/systems without support".

> Also, boost::atomic is
> better optimized than std::atomic on gcc prior to 4.7 and std::atomic
> cannot be used with structs with gcc prior to 4.8. Not sure what is
> the state of affairs on MSVC and other compilers.

It doesn't need to specifically map to std::atomic if any compiler support
is provided, we could build a list of compilers where std::atomic performs
at least as well as boost::atomic, or better.

something like:

if compiler is compiler A, and compiler A version < x: use boost::atomic
else if compiler is compiler B, and compiler B version < y: use
boost::atomic
...
else if compiler supports std::atomic: use std::atomic
else: use boost::atomic

As far as other libraries, I have benchmarked std::function vs.
boost::function on VS2012 and preliminary results suggests std::function is
at least as fast, if not faster compared to boost::function.


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