Quote:Original post by Emmanuel Deloget
Quote:Original post by jpetrie
So, short version is it looks like it's not legal, from my interpretation.
That would make the implementation of std::tr1::is_member_function_pointer<> and std::tr1::is_member_object_pointer<> a bit difficult, isn't it?
Those both operate on types and use partial specialization on a member [function] pointer
type, not a member [function] pointer
instance, thus dodging the issue.
14.1.4 legalizes pointers to members and to functions, so presumably member functions are legal. However, my understanding is that template parameters aren't subject to C++'s function overloading rules, and by extension, the original snippet is malformed, since they have the exact same signature, scope, and name. Fortunately, from the other thread, it looks like there's no reason that using actual overloading wouldn't be an option, which VC++9 groks properly:
struct Foo{ int a, b; int getB() const { return b; }};template <class T> struct Bar{ template < typename M > void add( M T::*m ) { ... } template < typename M > void add( M (T::*m)() const ) { ... }};int main(int argc, char** argv){ Bar<Foo> bar; bar.add( &Foo::a ); bar.add( &Foo::getB ); return 1;}
Alternatively, seperating them out into
add and
add_f is another option, which is the smallest change you can make to get the original snippet compiling under VC++9.