Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens to Boost libs after their inclusion in C++, other than usage with older-standard code?

I've noticed how in C++11, C++14 and onward, more and more Boost libraries are adopted/incorporated into the actual language standard (or into TS documents, which are likely to end up as part of the standard): Boost.optional, Boost.Any, Boost's threading library, smart pointers, etc. etc.

Are these libraries now maintained solely for usage with C++ code using an older version of the language standard, or do they have additional use? Specifically, are some of them considered alternative semantic variants to the choices of the C++ standards bodies?

like image 233
einpoklum Avatar asked Sep 27 '22 05:09

einpoklum


2 Answers

One difference between the Boost and standard versions is that Boost may have deprecated functionality (design aspects that were decided after discussion and experience to be problematic, and so weren't added to the standard) or extensions to the standard (because Boost may have more flexibility than the standard and so has features that didn't make it into the standard).

For example, Boost.Thread's documentation lists several deprecations and extensions compared to the standard library.

Depending on your needs, these may be good reasons to go with Boost over the standard.

like image 196
Josh Kelley Avatar answered Nov 15 '22 10:11

Josh Kelley


I don't work for/on the Boost project, but yes, I expect that these features will for some foreseeable future be maintained, so that those who use an older standard for whatever reason (Common reasons are "the whole project is written in C++03" or "We have been using compiler X version A.B.C and we worry about testing with a new compiler version D.E.F"). The more "customers" you have for a project, the more important it becomes to update things gradually, and not change old behaviour unless absolutely necessary or remove old features.

It is of course still possible to use these features even in "modern C++" applications that use C++11 or C++14 (and sometimes they have subtly different semantics and/or syntax, so the change required to use the "modern C++" variant is more than "remove the #include of that boost"). Just because there is a new way to do something doesn't mean that all code-writers IMMEDIATELY change all their code to use that way... So using the "old" way will still happen and exist for quite some time after it has been adopted. And sometimes there are subtle differences that require further alterations to the source code, so more "thinking/typing" needed, which means the change is less likely to happen. If it's just a "replace boost::thread with std::thread" then it may happen quite quickly. If you also need to change some other code involved (arguments change order, the syntax/meaning of things subtly change, etc), then it's more of a "proper work to solve this", which usually means it gets lower priority in the development team (especialy if it's also "not giving much in the way of benefit")

like image 31
Mats Petersson Avatar answered Nov 15 '22 08:11

Mats Petersson