Pointers to member functions and default parameters

From: Dave (better_cs_now_at_yahoo.com)
Date: 04/29/04


Date: Thu, 29 Apr 2004 10:58:25 -0700

Hello all,

At the line marked "Problem here???" below, I get successful compilation on
one platform and failure on another. What does the Standard say about this?
Is this a correct program? May a member function be called through a
pointer when some parameter default values are accepted (i.e. not all
parameters are passed)?

Thanks,
Dave

#include <iostream>

using namespace std;

class foo
{
   public:
      int do_it(int = 10) {return 42;}
};

template <typename RET, typename OBJECT_TYPE, typename PTR_TO_MEM_FUN>
RET call_it(OBJECT_TYPE &ds, PTR_TO_MEM_FUN pm)
{
   return (ds.*pm)(); // Problem here???
}

int main()
{
   foo bar;

   cout << call_it<int>(bar, &foo::do_it) << endl;
}