functors and STL, first cut

STL for_each takes a functor by value and hence all state stored in the
functor is lost unless the copy of the internal functor returned by
for_each is captured
STL functors with shared_ptr

functor copy returned by for_each need not be used to retrieve the count value as the same is now shared across all copied instances of the functor