//: C03:applyMember.h // From Thinking in C++, 2nd Edition // Available at http://www.BruceEckel.com // (c) Bruce Eckel 2000 // Copyright notice in Copyright.txt // applySequence.h modified to use // member function templates template class Seq> class SequenceWithApply : public Seq { public: // 0 arguments, any type of return value: template void apply(R (T::*f)()) { iterator it = begin(); while(it != end()) { ((*it)->*f)(); it++; } } // 1 argument, any type of return value: template void apply(R(T::*f)(A), A a) { iterator it = begin(); while(it != end()) { ((*it)->*f)(a); it++; } } // 2 arguments, any type of return value: template void apply(R(T::*f)(A1, A2), A1 a1, A2 a2) { iterator it = begin(); while(it != end()) { ((*it)->*f)(a1, a2); it++; } } }; ///:~