One of the containers introduced within TR1 (which is already widely available – both in gcc and Visual Studio) is a Tuple type, which is adopted from The Boost Tuple Library. Tuple types are very convenient at times; For example, it is possible to return multipe values from a function through a tuple, or write [...]
Archive for the ‘stl’ Category
Tuples
Posted in tr1 on 15/01/2010 | Leave a Comment »
Why do cin and cout have conversion to a void* and not bool?
Posted in stl on 11/10/2009 | 7 Comments »
Both std::cin and std::cout provide a conversion to a void* type, but not to a boolean: operator void* (); // zero if and only if fail() What use does a conversion to a boolean have, and which pitfalls does the current implementation save us from?
Different ways to iterate over a vector
Posted in stl on 28/08/2009 | 10 Comments »
Iterating over a vector is a pretty simple task we get to do pretty often. It can be achieved in quite a few ways: Using normal random access (operator[] with index). Using std::iterator. Using std::for_each algorithm. I set out to check the runtime differences between all these options, and the results turned out to be a [...]