Questions tagged [boost]

Boost is a large collection of high-quality libraries intended for use in C++. Boost is free, and is often considered a "second standard library".

What is Boost?

Boost is a large collection of high-quality libraries intended for use in C++. They are free and cover a large variety of categories. Boost is often considered a "second standard library", and many C++ problems are resolved by using Boost.

Boost provides free peer-reviewed portable C++ source libraries.

We emphasize libraries that work well with the C++ Standard Library. Boost libraries are intended to be widely useful, and usable across a broad spectrum of applications. The Boost license encourages both commercial and non-commercial

What can it do?

Boost covers every corner of programming, and continues to be improved and expanded.

It includes libraries for:

  • String and text processing
  • Containers
  • Iterators
  • Algorithms
  • Function objects and higher-order programming
  • Generic Programming
  • Template Metaprogramming
  • Preprocessor Metaprogramming
  • Concurrent Programming
  • Math and numerics
  • Correctness and testing
  • Data structures
  • Image processing
  • Input/Output
  • Inter-language support
  • Memory
  • Parsing
  • Programming Interfaces
  • Miscellaneous
  • Broken compiler workarounds

How do I use it?

The best part about Boost is that most of its libraries are header-only, so there's nothing to compile or link to. Simply download it, extract it into your favorite directory, tell your compiler where to find it, and use it!

However, there are some libraries that need to be compiled. These libraries are generally more heavy-weight, and/or rely heavily on platform-specific functionality. The libraries that need to be compiled are:

  • Date Time
  • Filesystem
  • Graph
  • Iostreams
  • Math/Special Functions*
  • MPI
  • Program options
  • Regular Expressions
  • Serialization
  • Signals
  • System
  • Test
  • Thread
  • Wave

Boost provides instructions on how to do this, and the process is mostly automated. Once built, most libraries will be automatically linked, if possible.

*Only when using the C99 math functions in <boost/math/tr1.hpp>


27545 questions
10 answers

How to install Boost on Ubuntu

I'm on Ubuntu, and I want to install Boost. I tried with sudo apt-get install boost But there was no such package. What is the best way to install Boost on Ubuntu?
  • 6,910
  • 3
  • 17
  • 21
6 answers

What is the usefulness of `enable_shared_from_this`?

I ran across enable_shared_from_this while reading the Boost.Asio examples and after reading the documentation I am still lost for how this should correctly be used. Can someone please give me an example and explanation of when using this class…
  • 5,566
  • 5
  • 24
  • 20
13 answers

How to use Boost in Visual Studio 2010

What is a good step by step explanation on how to use the Boost library in an empty project in Visual Studio?
  • 6,747
  • 6
  • 26
  • 36
10 answers

Should we pass a shared_ptr by reference or by value?

When a function takes a shared_ptr (from boost or C++11 STL), are you passing it: by const reference: void foo(const shared_ptr& p) or by value: void foo(shared_ptr p) ? I would prefer the first method because I suspect it would be faster.…
  • 22,240
  • 19
  • 65
  • 88
4 answers

How does libuv compare to Boost/ASIO?

I'd be interested in aspects like: scope/features performance maturity
  • 21,353
  • 10
  • 64
  • 97
4 answers

smart pointers (boost) explained

What is the difference between the following set of pointers? When do you use each pointer in production code, if at all? Examples would be appreciated! scoped_ptr shared_ptr weak_ptr intrusive_ptr Do you use boost in production code?
11 answers

How do you install Boost on MacOS?

How do you install Boost on MacOS? Right now I can't find bjam for the Mac.
Robert Gould
  • 68,773
  • 61
  • 187
  • 272
2 answers

Which Boost features overlap with C++11?

I put my C++ skills on the shelf several years ago and it seems now, when I need them again, the landscape has changed. We have got C++11 now, and my understanding is that it overlaps many Boost features. Is there some summary where those overlaps…
  • 2,363
  • 3
  • 16
  • 11
2 answers

CMake: Project structure with unit tests

I am trying to structure my project to include the production sources (in src subfolder) and tests (in test subfolder). I am using CMake to build this. As a minimal example I have the following files: CMakeLists.txt: cmake_minimum_required (VERSION…
  • 35,875
  • 47
  • 158
  • 240
25 answers

Get path of executable

I know this question has been asked before but I still haven't seen a satisfactory answer, or a definitive "no, this cannot be done", so I'll ask again! All I want to do is get the path to the currently running executable, either as an absolute path…
Ben Hymers
  • 25,586
  • 16
  • 59
  • 84
14 answers

How to determine the Boost version on a system?

Is there a quick way to determine the version of the Boost C++ libraries on a system?
Jan Deinhard
  • 19,645
  • 24
  • 81
  • 137
8 answers

How do you add Boost libraries in CMakeLists.txt?

I need to add Boost libraries into my CMakeLists.txt. How do you do it or how do you add it?
  • 2,209
  • 6
  • 21
  • 25
7 answers

Is it smart to replace boost::thread and boost::mutex with c++11 equivalents?

Motivation: reason why I'm considering it is that my genius project manager thinks that boost is another dependency and that it is horrible because "you depend on it"(I tried explaining the quality of boost, then gave up after some time :( ).…
  • 28,205
  • 28
  • 128
  • 277
5 answers

Boost Statechart vs. Meta State Machine

Apparently boost contains two separate libraries for state machines: Statechart and Meta State Machine (MSM). The taglines give very similar descriptions: Boost.Statechart - Arbitrarily complex finite state machines can be implemented in easily…
  • 6,650
  • 8
  • 42
  • 63
4 answers

Difference between `const shared_ptr` and `shared_ptr`?

I'm writing an accessor method for a shared pointer in C++ that goes something like this: class Foo { public: return_type getBar() const { return m_bar; } private: boost::shared_ptr m_bar; } So to support the const-ness of…
Dave Lillethun
  • 2,978
  • 3
  • 20
  • 24
2 3
99 100