The overload resolution here seems to hinge on the question of how exactly the transformed function types are produced in the partial ordering test ([temp.func.order]/3).
For the member overload, if we consider the actual template in question to be
template <typename U> C<D>::operator+(U)
then the partial ordering process must fail to effect a choice (there is an implicit C<D>& parameter). On the other hand, if we consider it to be
template <typename T> template <typename U> C<T>::operator+(U)
then the non-member is more specialized (there is an implicit C<T>& parameter) and must win overload resolution.
I believe that the former interpretation is the correct one, because if we follow the standard's general philosophy that an X template is only a blueprint for an X and not an X itself, then it also follows that a function template member of a class template is not actually a function template, and therefore the partial ordering process, which orders "function templates", must take as input the function template member of the specialization C<D>. However, this argument is obviously not a very strong one.
- Is there some wording in the standard that tells us which interpretation is correct?
- If not, this is obviously a defect. If so, is the fact that GCC and Clang diverge evidence that this is not clear enough, so some more wording needs to be added anyway?