|
Boost Users : |
From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2005-02-15 11:58:27
Jonathan Turkanis wrote:
> Sharon Galtzur wrote:
>
>
>>Thanks for the reply. The thing i dont understand is this :
>>template <class T> void f(int (T::*)(int)) will match any member
>>function with specific signature (receiving int and returning int).
>>But not all classes have such function. So in this case how will a
>>class F { } be matched ?
>
>
> No member of the given type need exist for the pointer-to-member type to be
> well-formed. Consider:
>
> struct C { };
>
> typedef void (C::*mem_fun) (std::string);
>
> The later expression defines a type which can have no instances,
<snip>
Actually it can:
struct D : C { void foo(std::string); };
mem_fun mf = static_cast<mem_fun>(&D::foo);
Not that I'd recommend doing that, as it invites type errors.
Ben.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net