Listing 6

template<typename IterableConcept>
struct IterableExtension : IterableConcept {
  typedef typename IterableConcept::Iterator Iterator;
  typedef typename IterableConcept::Item Item;
  template<typename FunctionT>
  void ForEach(FunctionT f) {
    Iterator first = IterableConcept::Begin(), last = 
IterableConcept::End();
    while (first != last) f(*first++);
   }
  bool IsEmpty() {
    return IterableConcept::Begin() == IterableConcept::End();
  }
  int Count() {
    int ret = 0;
    Iterator first = IterableConcept::Begin(), last = 
IterableConcept::End();
    while (first != last) ++first, ++ret;
    return ret;
  }
};