What Are the Advantages of Using the C++ Boost Libraries

What are the advantages of using the C++ Boost libraries?

Boost is used so extensively because:

  • It is open-source and peer-reviewed.
  • It provides a wide range of platform agnostic functionality that STL missed.
  • It is a complement to STL rather than a replacement.
  • Many of Boost developers are on the C++ standard committee. In fact, many parts of Boost is considered to be included in the next C++ standard library.
  • It is documented nicely.
  • Its license allows inclusion in open-source and closed-source projects.
  • Its features are not usually dependent on each other so you can link only the parts you require. [Luc Hermitte's comment]

Benefits and portability of Boost Library

Boost is organized by several members of the standard committee.

So it is a breeding ground for libraries that will be in the next standard.

  1. It is an extension to the STL (it fills in the bits left out)
  2. It is well documented.
  3. It is well peer-reviewed.
  4. It has high activity so bugs are found and fixed quickly.
  5. It is platform neutral and works everywhere.
  6. It is free to use.

With tr1 coming up soon it is nice to know that boost already has a lot of the ground covered. A lot of the libraries in tr1 are basically adapted directly from boost originals and thus have been tried and tested. The difference is that they have been moved into the std::tr1 namespace (rather than boost).

All that you need to do is add the following to your compilers default include search path:

<boost-install-path>/boost/tr1/tr1

Then when you include the standard headers boost will automatically import all the required stuff into the namespace std::tr1

For Example:

To use std::tr1::share_ptr you just need to include <memory>. This will give you all the smart pointers with one file.

How important is Boost to learn for C++ developers?

I think anyone that is seriously considering C++ development as a career should learn Boost, and learn it well. Once you get into serious programming you will realize how beneficial these libraries can be and how much more productive they can make you. Not only are they cross-platform, but once you get into data crunching with large numbers, the math libraries especially will seem like a gift from above.

Use boost C++ libraries?

What exactly is Boost?

Boost is a collection of useful and extremely high-quality libraries for C++ that complement the rather small standard library.

What are the most import reasons to use Boost?

Boost offers high-quality tools that are missing from C++. Their use is extremely varied though so whether Boost is for you depends entirely on your needs. But I can safely say that every large enough C++ code base would benefit from using Boost.

Some of the most versatile parts are the shared_ptr (a reference-counting smart pointer that helps prevent memory leaks in pointer-rich code), array which provides a very convenient wrapper around C-style arrays of fixed size and other small odd bits which have been integrated into the next C++ standard.

Is it fully cross-platform?

Almost always yes. This is one of the main qualities of Boost.

Is there any link to a page describing all the modules of Boost in one or two sentences?

There is indeed.

What are the advantages and disadvantages of using boost::iterator_facade?

If maintaining your own iterator types becomes a burden then switch to boost. They are well specified and tested and less likely to have bugs.

What are the advantages of boost::noncopyable

Summarizing what others have said:

Advantages of boost::noncopyable over private copy methods:

  1. It is more explicit and descriptive in the intent. Using private copy functions is an idiom that takes longer to spot than noncopyable.
  2. It is less code / less typing / less clutter / less room for error (the easiest would be accidentally providing an implementation).
  3. It embeds meaning right in the type's metadata, similar to a C# attribute. You can now write a function which accepts only objects which are noncopyable.
  4. It potentially catches errors earlier in the build process. The error will be presented at compile-time rather than link-time, in the case that the class itself or friends of the class are doing the erroneous copying.
  5. (almost the same as #4) Prevents the class itself or friends of the class from calling the private copy methods.

Advantages of private copy methods over boost::noncopyable:

  1. No boost dependency


Related Topics



Leave a reply



Submit