dimanche 19 avril 2020

Hidden friend template function not found by ADL

This is my code:

namespace Bar {
template<typename...Types>
class Foo {
public:
    template<class T>
    friend T* get_if(Foo<Types...>& f) {
       return nullptr;
    }
};
}
int main() {
  Bar::Foo<int, double> f;
  get_if<int>(f);
  return 0;
}

From my understanding get_if is an hidden friend and it can be found only by ADL. However get_if is not found (at least compiling with GCC 7), why?

Aucun commentaire:

Enregistrer un commentaire