views:

504

answers:

5
+5  Q: 

Boost cheat sheet

I just had a hell of a project doing simple operations on C++, then when I was almost completely done with the project I found out that all this stupid tasks required just a portion of boost. This was quite frustrating and let me wondering how many of these annoying problems could be solved with a single function of the boost libraries.

So the question is, is there any cheat sheet for the boost libraries? I mean, that I can say right away, I should look at this part of boost to solve the problem. Most of the times the description that appear in the main page of boost doesn't even explain what it is intented or, specially for somebody whose not use to all these C++ specific words.

+4  A: 

Well, looking at the library list here or here are how I familiarized myself with boost. Just click through each so you can get a general idea of what the libraries can do. Then if you ever need something you might recall that functionality was in boost.

I suppose you could also try searching the site with Google for the keywords you're trying to use on a particular problem.

Throwing away code after you've written it is hard to do, but the right thing to do. Coincidentally, I asked a question yesterday, and after implementing the whole thing, someone found it in boost. I just source controlled it, then deleted it. Think of it as a learning exercise :)

GMan
+8  A: 

I personally find the Boost Libraries page to be much easier to navigate than the main page of Boost.

That Boost Libraries page is the closest I'm aware of to a cheat sheet. Other than that, all I can recommend is to periodically browse the Boost docs as you start work on new areas of your project; libraries that you previously saw little need for will start to make sense as you see how to apply their functionality to your project and as you learn more of C++ to see how C++-specific features like type traits can benefit you.

You might also try Beyond the C++ Standard Library: An Introduction to Boost. I've not read it.

Josh Kelley
An Introduction to Boost is a good book, but it is more of a "book" than a "cheat sheet."
Dan Hook
+1 for BtCSL, I have read it.
MSalters
Excellent book. Definitely worth reading.
Ferruccio
+1  A: 

I've used the Boost libraries a lot and it is hard to keep track of everything that is in them. There are a couple of heuristics I use to see if it's worth checking the Boost Libraries page.

Is the problem I'm having one that many C++ developers are likely to have? Is there another programming language in which this problem is easily solved? The Boost developers love fixing the perceived shortcomings of C++. Does the problem involve a lot of repetitive coding? Does the problem involve math?

Even still, it's possible to miss things. I read some code that made good use of type traits but had lots of repetitive code that could have been eliminated by the operators library. I asked the author why he didn't use it and he said "I hadn't learned about it yet." Learning the Boost libraries, like anything, is a gradual process.

Dan Hook
A: 

I agree that it is not always obvious that a problem that you try to solve is already in boost.
Many questions in SO have answers referring to boost, so for me, SO has been some kind of cheat sheet (albeit not in the traditional sense).
Don't forget that it's not because something is in boost, it is naturally the best solution for your problem.

stefaanv
+4  A: 

In my opinion, there are three different kinds of boost libraries:

  1. A library like the template meta-programming library (boost::mpl) introduces a completely new concept (new to the uninitiated) to c++ programming. Once you've understood the concept, you will likely encounter many different situations in which you instinctively think "This can probably be done using MPL and I just have to figure out how"

  2. A few libraries are simple to understand and can be frequently used: boost::function, boost::bind, the iterator library, boost range and operator to name a few. They make familiar things much easier to do and as other posters have said reduce the need for repetitive code.

  3. Then there are all the libraries that fill the need for extensive standard libraries that Java has had for a long time: parser generation using boost::spirit, graph libraries, asynchronous in- and output etc. These can be discovered one at a time. You should definitely look here before you go out and implement your own language parser :-)

Sebastian