I've run into a rather perplexing issue. I've managed to distill it down into the code here: http://goo.gl/TYqayI
I'm basically trying to overload a function based on whether the given value is a pointer-to-member, pointer-to-const-member, or a pointer-to-member-function (accepting one argument and returning void). According to the latest versions of MSVC and Clang, this is ambiguous! But according to the latest version of GCC this is fine. I'm gonna go with GCC on this one, because I can't see how this is ambiguous at all. A field is either const or not, and pointers to member functions are unrelated to pointers to members, so determining the correct overload should be a piece of cake, right?
That's why the non-const overload is there. Besides, currently it thinks all three functions are candidates, while really it should be just one (the one accepting a pointer-to-member-function).
Using some SFINAE, I've managed to modify the code so that the over loads a no longer ambiguous on any compiler, see here: http://goo.gl/zVcoKo
(I'd also like to point at that this proves that the "const" in the second overload, DOES in fact have an effect: it declares it as a "pointer-to-const").
While it works well, its rather frustrating that I have to resort to using that. It seems that some compilers think that "[signature] [owner name]::*" is a valid declaration for a pointer-to-member-function, but I've never seen that anywhere. I'm not sure what the standard says about it though.
Thanks for the response, I never knew you could do that! One thing I love about C++ is there's always more to learn, so you never get bored! (Though you might get frustrated)
Checked this with the standard:
If the type of a function is unqualified, it could be the type of either a member function or a non-member function.
If the type of a function is cv qualified or ref qualified, it can only be the type of a non-static member function.
clang++ appears to be the only mainstream compiler that is fully conforming with respect to this.
g++ (5.1) is broken for ref qualified function types
Microsoft does not support ref qualified member functions at all.
The latest version of MSVC actually does have ref-qualified member functions, 2015 RC. The previous versions of MSVC are crap anyway, seeing as classes don't get auto-generated move constructors, and half the type_traits stuff doesn't work.
It seems that they're still not quite fully supported though: the editor won't let me collapse functions that have ref-qualifiers.