Boost has been used in C++03 for years, so its the natural choice to use boost versions still in C++11 which are now part of std::, in order to be able to interface with C++03. But also some people will be happy to use C++11, and prefer the Standard Library over using boost.
Replaceable by C++11 language features or libraries
<cmath>
, see the list below
log1p
, expm1
cbrt
, hypot
acosh
, asinh
, atanh
TR1 (they are marked in the documentation if those are TR1 libraries)
Features back-ported from C++11:
Replaceable by C++17 language features:
<cmath>
(Special Math IS), see the list below
The standard team is still working on it:
A large part of MPL can be trimmed down or removed using variadic templates. Some common use cases of Lexical cast can be replaced by std::to_string and std::stoX.
Some Boost libraries are related to C++11 but also have some more extensions, e.g. Boost.Functional/Hash contains hash_combine and related functions not found in C++11, Boost.Chrono has I/O and rounding and many other clocks, etc. so you may still want to take a look at the boost ones before really dismissing them.
Actually, I don't think the boost libraries are going to become legacy.
Yes, you should be able to use std::type_traits
, regex
, shared_ptr
, unique_ptr
, tuple<>
, std::tie
, std::begin
instead of Boost Typetraits/Utility, Boost Smartpointer, Boost Tuple, Boost Range libraries, but there should in practice be no real need to 'switch' unless you are moving more of your code to c++11.
Also, in my experience, the std
versions of most of these are somewhat less featureful. E.g. AFAICT the standard does not have
bool boost::basic_regex<>::empty()
) and othe interface differences
Lazy, expression template-based lambdas; they have inevitable benefits in that they can be polymorphic today, as opposed to C++11. Therefore they can often be more succinct:
std::vector<int> v = {1,2,-9,3};
for (auto i : v | filtered(_arg1 >=0))
std::cout << i << "\n";
// or:
boost::for_each(v, std::cout << _arg1);
Most definitely, this still has some appeal over C++11 lambdas (with trailing return types, explicit capturing and declared parameters).
Also, there is a BIG role for Boost, precisely in facilitating path-wise migration from C++03 to C++11 and integrating C++11 and C++03 codebases. I'm particularly thinking of
boost::result_of<>
and related)Just my $0.02
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With