Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Boost has recently become available on the project on which I\'m working, and I

ID: 642506 • Letter: B

Question

Boost has recently become available on the project on which I'm working, and I don't have much experience with it. The library has so many parts and features that it's hard to know where to get started in learning it - especially since I'll be trying to learn it while making production code (so it can't slow me down too much).

I would greatly appreciate it if someone could list around 3 to 5 features which are very useful in general, every-day programming and state why they're useful. Then I can start to learn those and use them - it'll at least give me a foothold in the library and a friendly place to start learning it/applying it :)

Thanks in advance!

Explanation / Answer

If you are using a pre TR1 compiler then smart pointers
boost::shared_ptr
boost::weak_ptr
boost::scoped_ptr

boost::scoped_array
boost::shared_array
If your compiler already has smart pointers use them.
The reason is obvious C++ without smart pointers is basically not C++

The boost ptr_contaier libraries.
All the STL containers re-implemented specifically to hold pointers. Not only do the containers take ownership of the pointers so that when the container is destroyed it automatically destroys all the pointers. BUT it also provides accesses to elements as normal object references (not pointers) this makes it easy to use the objects in standard algorithms without wrapper functors.

The boost lambda libraries. (see comment below)
The STL functors and binders are OK for simple things. But boost::lambda took it the next step and makes things a lot simpler when using the standard algorithms.

boost::any and boost::variant
When you need to hold objects without wanting to know their exact type.

multi Index Containers
Containers that allow multiple different ways to access the elements.
Gone are the days when you have a vector of objects and a separate map for quick searching vector. This cuts down on the boilerplate you need to write to maintain the two containers when inserting/deleting elements into the containers.

boost::lexical_cast
Probably the least useful in real life but a lot of fun to play with is boost::lexical_cast. It converts any object to/from a string (as long as that type has the appropriate << and >> operators defined). Very useful for dumping error messages when de-bugging.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote