Use the iterator_type

This is a port of 513f011080a5b20c525e01fba9727f5dbd50a4ca to the other example.
Use std::accumulate instead of the boost's counterpart
Use C++11's native for construct instead of BOOST_FOREACH
Merge pull request #2 from jktjkt/c++11

Use C++11's native features in preference to Boost