Boost library

Since I started using this site, I keep hearing about the Boost library. I am wondering what are the main benefits of the Boost library (hence why should I use it) and how portable is the Boost library?

+49
c ++ boost
Sep 29 '08 at 15:43
source share
12 answers

Boost is organized by several members of the standard committee.
Thus, this is an environment for libraries, which will be in the next standard.

  • This is an extension for STL (it fills the remaining bits)
  • This is well documented.
  • He is well versed.
  • It is highly active, so errors are detected and corrected quickly.
  • This platform is neutral and works everywhere.
  • It is free to use.

When tr1 arrives soon, it's nice to know that boost already has a lot of land. Many tr1 libraries are mainly adapted directly from the original originals and thus have been tried and tested. The difference is that they were moved to the std :: tr1 namespace (and not to boost).

All you have to do is add the following default compilers to include the search path :

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

Then, when you include standard headers, boost automatically imports all the necessary materials into the std :: tr1 namespace

For example:

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

+66
Sep 29 '08 at 15:48
source share

You can simply read the Boost Background Information page to get a quick overview of why you should use Boost and what you can use it for. It takes a few minutes.

+17
Sep 29 '08 at 15:48
source share

99% portable.

I would say that it has quite a few libraries that are really useful when you discover a need that is solved by raising. Either you code it yourself, or use a very robust library. If you leave the source of the shelf for things like Multi-Index, Lambda, Program Options, RegEx, SmartPtr and Tuple, this is amazing ...

It is best to spend some time looking at the documentation for different libraries and evaluating whether it can be useful to you.

Worthy!!

+13
Sep 29 '08 at 15:52
source share

Boost is a collection of C ++ libraries. 10 of which are included in tr1 from C ++ 0x.

You can start with boost here .

+11
Sep 29 '08 at 15:45
source share

You get a lot of things that appear in C ++ 0x. But besides this generality, some of the best features are a simple regex library, a casting library for casting from strings in ints (Lexical cast):

 int iResult = 0; try { iResult = lexical_cast<int>("4"); } catch(bad_lexical_cast &) { cout << "Unable to cast string to int"; } 

A library of date and time , among others ...

 using namespace boost::gregorian; date weekstart(2002,Feb,1); date thursday_next = next_weekday(weekstart, Thursday); // following Thursday 

There is also a Python interface (Boost Python), lexer / parser DSL (Boost Spirit):

 // A grammar in C++ for equations group = '(' >> expression >> ')'; factor = integer | group; term = factor >> *(('*' >> factor) | ('/' >> factor)); expression = term >> *(('+' >> term) | ('-' >> term)); 

and it just scratches the surface ...

+11
Sep 29 '08 at 15:46
source share

Boost is great, but just playing Devil Advocate here are a few reasons why you can't use Boost:

  • Sometimes it is not possible to compile / work correctly with old compilers.
  • It often lengthens compilation times with more than less-fitting templates.
  • Some Boost code may not do what you think it does. Read the documentation!
  • Broken patterns can lead to unreadable error messages.
  • Violation of patterns can lead to complex code execution in the debugger.
  • This is the bleeding edge of C ++. The next version of Boost can no longer compile to your current (older) compiler.

All this does not mean that you should not look at the Boost code and receive ideas yourself, even if you do not use Boost as is.

+11
Sep 29 '08 at 20:51
source share

Boost is a collection of high-quality C ++ peer-reviewed libraries that emphasize portability and correctness. It acts as the basis for the deactivation of new additions to the language and standard library. Visit their website for more details.

+5
Sep 29 '08 at 15:49
source share

Enhance the benefits: It is widely available, it will be portable to any modern C ++ compiler or to any platform.
The functions are platform independent; you do not need to learn a new thread design for each new structure.
It encapsulates many specific platfom functions, such as file systems in a standard way.

This is what C ++ was supposed to supply! A lot of the popularity of Java was that it comes with a standard library to do prety a lot of everything you wanted. C ++, unfortunately, only inherited the limited standard C / Unix functions.

+4
Sep 29 '08 at 15:50
source share

shared_ptr and weak_ptr , especially in multi-threaded code, are only worth raising. BOOST_STATIC_ASSERT also pretty cool for doing compile-time checks.

The fact that many classes and utilities in boost are in the headers, which means you can get a lot of functionality without compiling anything at all, is also a plus. Portability is usually not a problem unless you use an extremely old compiler. I once tried to get MPL to work with VC6, and it completely printed out 40,000 warnings / internal errors. But overall, most of the library should work regardless of your platform or compiler provider.

Take into account the fact that quite a few things from Boost are already in TR1 and most likely will be in the next version of the C ++ standard library. This is a pretty big endorsement.

+4
Nov 08 '08 at 22:18
source share

Boost is a very extensive library of (usually) common constructs that can help in almost any application. This can be shown by the fact that many boost components are included in the C ++ 0x specification.

It also carries over, at least to major platforms, and should be portable to just about anything that is compatible with a C ++ compiler that is compliant with standards.

The only warning is that there can be many interdependent dependencies between extended libraries, which makes it difficult to select only a specific component for distribution (except for the entire boost library).

+3
Sep 29 '08 at 15:47
source share

All of the above, plus it encourages a lot of modern, advanced C ++ methods. This improves the quality of your code.

+3
Sep 29 '08 at 16:11
source share

Also note that most forcing are templates, so construction is not required
(just include the correct header files).

Several parts that require construction are optional:
They can be built independently of each other, thereby preventing unnecessary bloating of unnecessary code.

+1
Jan 19 '09 at 10:06
source share



All Articles