|
Boost Users : |
From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-02-15 15:06:46
Ben Hutchings wrote:
> 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.
Oops! I should have made C sealed ;-)
>
> Ben.
Jonathan
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