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).
Continue reading Different ways to iterate over a vector
The classes istringstream and ostringstream can be utilized to create generic templated toString() & fromString() functions. This functionality (which is built-in in many languages, such as Java) may come in very handy, quite often.
Continue reading Implementing toString() and fromString() using std::stringstream
From time to time we are required to print out a vector. It is possible to utilize the standard copy algorithm (std::copy) to do just that.
Continue reading Printing using std::copy