4.1.0: pointer to member type deduction in template parameter

Daniel Llorens del Río daniel.llorensdelrio@epfl.ch
Thu Mar 2 11:44:00 GMT 2006


Hi,

I have this code which compiles cleanly under 4.0.1.

#include <cassert>

struct A
{
     int f() const { return 1; }
};

A a;

template <class R, class S>
inline R wrap(R (S::*f)())
{
     return (a.*f)();
}

int main()
{
lineX:    assert(wrap(&A::f) == 1);
           return 0;
}

Under 4.1.0, I get the error

program.C: In function 'int main()':
program.C:linex: error: no matching function for call to 'wrap(int  
(A::*)()const)'

and I must modify the declaration of warp() to

inline R wrap(R (S::*f)() const)

to make it compile.

Is 4.1 right? I would have tought that 'R (S::*)() const' is included  
in 'R (S::*f)()'.

Thanks in advance,

	Daniel.



More information about the Gcc-help mailing list