Archive for the ‘stl’ Category
Tuples
Posted 15/01/2010
on:- In: tr1
- Leave a Comment
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 more intuitive and expressive code by utilizing tuples.
In this post we will examine the functionality offered by the new Tuple container, and have a go at profiling its performance. Actually, the results of said profiling were a small (pleasant) surprise to me.
- In: stl
- 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?
- In: stl
- 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 little surprising (or not).
Recent comments