Next, GCC mixes the struct name template with the function of the template member name class A , while Clang compiles fine ( live example ):
template<typename T> struct name {}; struct A { template<bool B> void name() { } }; template<bool B, typename T> void f(T& x) { x.template name<B>(); }
The function f apparently intended to be called with an argument of type A in this example, but it could be anything, so f should remain a template function.
I don't care which compiler is correct, I only need a workaround because I really don't know any syntax except
x.template name<B>();
to call a member function, and I donβt see how using a declaration or any other way of disambiguating can be applied.
EDIT Yes, now I tried a more explicit syntax
xT::template name<B>();
which works but really ugly. Any way to make a concise syntax work? Otherwise, it would be preferable to change one of the two names to start with ...
EDIT2 My initial version of f works with a universal T&& link that needs the ugliest
using X = typename std::remove_reference<T>::type; xX::template name<B>();
in case T is a reference ... And all this for a simple function call.
c ++ templates template-function
iavr
source share