English 中文(简体)
Boost cheat sheet [closed]
原标题:
  • 时间:2009-11-19 19:09:40
  •  标签:
  • c++
  • boost

Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.

Closed 9 years ago.

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.

最佳回答

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.

问题回答

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 :-)

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 :)

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.

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.





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签