5 // From B. Strousjoup, "The C++ Programming Language, Third Edition", p. 514
6 template<class T> class Sum {
9 Sum(T i = 0) : res(i) { }
10 void operator() (T x) { res += x; }
11 T result() const { return res; }
17 * Rename the application operator to call() for Ruby.
18 * Note: this is normally automatic, but if you had to do it yourself
19 * you would use this directive:
21 * %rename(call) *::operator();
24 // Instantiate a few versions
25 %template(IntSum) Sum<int>;
26 %template(DoubleSum) Sum<double>;