How can I workaround this clang warning? This appears quite frequently with code that includes STL <set>
and additionally has a templatized set()
function.
I don't want to disable the warning globally, but also not manually for every file where <set>
is included (too many).
template<typename T> struct set{};
template<typename T> struct trait { typedef const T& type; };
struct Value {
template<typename T> void set(typename trait<T>::type value) {}
};
void foo() {
Value v;
v.set<double>(3.2);
}
clang.cpp:8:9: warning: lookup of 'set' in member access expression is ambiguous; using member of 'Value' [-Wambiguous-member-template] v.set(3.2); ^ clang.cpp:4:29: note: lookup in the object type 'Value' refers here template void set(typename trait::type value) {} ^ clang.cpp:1:29: note: lookup from the current scope refers here template struct set{}; ^ 1 warning generated.
The obvious solution would be to not use templatized set()
methods but that seems rather limiting.