Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we prefer Boost or standard lib? [closed]

Tags:

c++

boost

I'm reading Boost array documentation and I see this line :

If you are using C++11, you should consider using std::array instead of boost::array

I was under the impression that Boost, for its major libs, was always preferable to standard lib because :

  • boost will never perform worse than the standard lib
  • boost may provide more features
  • boost is at last of equal quality than standard lib (people writing the C++ standard are active boost developpers/supervisors)
  • major boost features end up in the standard lib a few years later

So am I right to prefer boost over stdlib ?

If not / more complicated, which of my assumptions are to be corrected ?

like image 815
Offirmo Avatar asked Jan 15 '13 09:01

Offirmo


People also ask

Is Boost better than STD?

boost will never perform worse than the standard lib. boost may provide more features. boost is at last of equal quality than standard lib (people writing the C++ standard are active boost developpers/supervisors) major boost features end up in the standard lib a few years later.

Is Boost library still useful?

After 20 years of active Boost development, it's now recognized as a very powerful C++ library, for each major version many C++ libraries from the community were added. The Boost reviewers have an advanced C++ skills and their contributions guarantee a high quality for many years.

Is Boost better than STL?

Ultimately, you should learn both. But STL can be learned in isolation, whereas boost won't make much sense until you understand the STL, since that's what Boost is modeled on, and designed to extend. So learn to use the STL as part of learning c++.

Is Boost library fast?

boost and the C++ standard libraries are used to produce extremely fast production implementations.


2 Answers

I think you should use standard lib when available because... it's standard and comes with the compiler. Besides, if you use boost you need an annoying external dependency.

So, my advice is: use std when possible. If you're writing portable code, that must also be compiled with old compilers, you can consider to use your own namespace (e.g.: cxx0x) that embeds std or boost namespace according to the compiler you're using (this is called namespace alias):

#ifdef COMPILER_HAS_CXX0X     #include <memory>     namespace cxx0x = std; #else     #include <boost/shared_ptr.hpp>     namespace cxx0x = boost; #endif  ...  cxx0x::shared_ptr< MyClass > = ... 
like image 197
Daniele Pallastrelli Avatar answered Sep 28 '22 01:09

Daniele Pallastrelli


Taken from the Boost people themselves:

Why should an organization use Boost?

In a word, Productivity. Use of high-quality libraries like Boost speeds initial development, results in fewer bugs, reduces reinvention-of-the-wheel, and cuts long-term maintenance costs. And since Boost libraries tend to become de facto or de jure standards, many programmers are already familiar with them.

Ten of the Boost libraries are included in the C++ Standard Library's TR1, and so are slated for later full standardization. More Boost libraries are in the pipeline for TR2. Using Boost libraries gives an organization a head-start in adopting new technologies.

Many organization already use programs implemented with Boost, like Adobe Acrobat Reader 7.0.

like image 44
dsgriffin Avatar answered Sep 28 '22 01:09

dsgriffin