This compiles fine in clang 3.3:
template <typename T>
struct M;
template <typename R, typename C, typename... A>
struct M <R (C::*)(A...)> { };
template <typename R, typename C, typename... A>
struct M <R (C::*)(A...) &> { };
but fails in gcc 4.8.1:
[...] error: redefinition of ‘struct M <R (C::*)(A ...)>’
struct M <R (C::*)(A...) &> { };
^
[...] error: previous definition of ‘struct M <R (C::*)(A ...)>’
struct M <R (C::*)(A...)> { };
^
When used in different contexts, this results in all sorts of unexpected compiler behaviour like crashing or internal compiler errors.
I understand ref-qualified member functions are referred to as "rvalue references for *this" (N2439) in the standard, and are supported by gcc 4.8.1.
The problem here is to use them as template arguments, where gcc does not appear to discriminate between a ref-qualified and an ordinary member function type.
clang's implementation of the std library seems to detect whether this feature is supported by
__has_feature(cxx_reference_qualified_functions)
So, is this use of ref-qualified functions standard, or a language extension?