tags:

views:

466

answers:

7

I hear a lot about boost here and I am beginning to think it could help a lot with my software development. More so in concurrency and memory management in my particular case as we have had a lot of bugs in this area.

What are the key language features I need to polish up on to effectively benefit from using boost and to shorten the learning curve? I have seen that function objects are commonly used so I would probably need to polish up on that.

Additionally, are there any tutorials and 101 resources I can quickly look at to just get a feel and understanding on using boost.

I realise there is a lot boost offers and I have to pick the right tools for the right job but any leads will help.

Related

+3  A: 

What are the key language features I need to polish up on to effectively benefit from using boost and to shorten the learning curve?

  • Templates
  • Functors
  • Exceptions
  • STL
    • Iterators
    • Algorithms
    • Containers

... among others.

are there any tutorials and 101 resources I can quickly look at to just get a feel and understanding on using boost.

Boost is well documented. Start here.

There are too many libraries to get lost. I'd say start with something simple, maybe smart pointers or Boost.Test (Unit Test framework) -- which will quickly help you get started. Also, try to think of a problem you cannot solve with the STL easily. Then look up Boost documentation or post here.

If you are comfortable with functional programming look at MPL/Lambda libraries.

dirkgently
Thanks. Should clarify I am already confortable with C++ including the use of STL, Excpetions and Templates.
MeThinks
A: 

I think shared_ptr sould be the easiest place to start . Start using it inplaces of simple pointer or auto_ptr data types.

You can also look into weak_ptr.

Alien01
simply using shared_ptr instead of auto_ptr is not appropriate in all situations. Look up "Ownership Semantics" It is the key to memory management in C++.
Martin York
+4  A: 

Learning boost is discussed here. As for language features that are useful? All of them. C++ is a dangerous language to use if you don't know enough of it. RAII, functors/function objects and templates probably cover the most important aspects. Boost is designed similarly to the STL, so knowing your standard library is essential. Boost itself uses a lot of template metaprogramming, but as a library user, you won't often need that (unless you start playing with Boost.MPL)

Bugs related to memory management are a good indicator that it's C++, rather than Boost you need to brush up on. The techniques for handling memory safely are well known, and not specific to Boost. (With the obvious exception of Boost's smart pointers). RAII is probably the most important concept to understand to deal with this kind of issues.

jalf
+4  A: 

Boost has an unimaginable number of libraries. Easy ones to get started on are

  • noncopyable
  • array
  • circular_buffer
  • foreach
  • operators (one of my personal favorites)
  • smart_ptr
  • date_time

More advanced ones include

  • lambda
  • bind
  • iostreams
  • serialization
  • threads

Getting used to boost takes time, but I assure you it will make your life much better. Plus, looking at how the boost libraries are coded will help you get better at c++ coding, especially templates.

You mentioned what should you look up before trying boost. I agree that function objects are a great thing to research. Also, make sure to look up about template programming. A common problem to make sure you know is when to use the typename qualifier for dependent types. For the most part, however, the libraries are very well documented, with examples and reference materials.

rlbond
Fantastic. This looks looks gradual and will probably take this approach including all the other suggestions from the answers here. Thanks
MeThinks
+3  A: 

The first ting IMO are smart pointers. Integration into new code is simple, and usually not a problem for existing code. They make memory management easy, and work for many other ressources, too.

C++ gives you the power to manage your own memory, smart pointers let you (mostly) wing it when you don't need to.

The second would be - as you mentioned - function objects, they close a big gap within C++ that is traditionally solved through inheritance, which is to strong of a coupling in many cases.

I have only little experience with boost outside these two, but most of the remainder is fairly "situational" - you may or may not need it. Get an overview over the libraries, and see what you need.

boost::any and boost::variant are good of you need a variant data type, with two different approaches.

boost::regex if you need some text parsing.

boost::thread and boost::filesystem help you write portable code. If you already have good platform specific libraries, you might not need them - but they are better than API or C++ level in any case.

Maybe you like my introduction to boost smart pointers, and a rather unorthodox use for them.

peterchen
+1  A: 

Try Björn Karlsson's book: Beyond the C++ Standard Library: An Introduction to Boost. Its pretty straightforward and easy to grasp. I read this after I'd finished Scott Meyers three c++ books (effective series).

Schildmeijer
A: 

After reading Beyond the C++ Standard Library: An Introduction to Boost, I would recommend casually browsing the documentation on boost.org, just to get an idea of what's available. You can do a deep dive into a specific boost library when it looks like a good fit for a particular application.

Ferruccio