c++argument-dependent-lookup

Why does ADL fail on a dependent typename?


I noticed that get<0>(t) fails to be resolved to std::get<0>(t) if its argument's type depends on a template parameter:

template <typename T>
void foo(T) {
  std::tuple<T> tup{0};
  get<0>(tup) = 1; // error: 'get' was not declared in this scope; did you mean 'std::get'?
}

This works fine if foo is not a template (i.e. if tup is declared as std::tuple<int>) or with using std::get;. Shouldn't it also work in a function template where ADL is often extra useful?


Solution

  • Looks like a compiler error on gcc up to and including 10.2. Subsequent versions fix this.