
Peter Dimov wrote:
Tobias Schwinger wrote:
[...]
typedef int my_const_function() const;
Where do I find it in the standard and/or what should happen in the following two cases?
Don't know about the standard, but...
template<typename T> struct remove_member_pointer { typedef T type; };
template<typename T, typename C> struct remove_member_pointer< T C::* > { typedef T type; };
remove_member_pointer< my_const_function >::type // <-- case 1
The specialization doesn't match, because int () const is not of the form T C::*, so the primary template is selected and echoes my_const_function back.
Ooops -- of course! Actually I wanted to write "my_const_mem_fun_ptr" - fortunately you applied some intuitive error correction on the fly...
template<typename T, typename C> struct add_member_pointer { typedef T C::*type; };
class X;
add_member_pointer< my_const_function, X >::type // <-- case 2
int (X::*) () const.
If you pass that to remove_member_pointer, it would give you my_const_function.
Makes sense. Would be too great if /all/ compilers behaved this way... Thanks, Tobias