Template specialization does not see a function at its instantiation point

I do not understand why this is wrong [/ p>

#include <iostream>
using namespace std;

struct CL{};

template <typename T>
void fnc(T t)
{
    f(t);
}

namespace NS {
    void f(CL){}
    void fn() {fnc(CL()); /*error is here*/}
    //point of instantiation fnc<CL> is here (in namespace scope,
    //according to 14.6.4.1/1)
}

int main(){}

The call f(t)to the template function fncdepends on the template parameter, and then the name search should be at the creation point. I saw Standard (C ++ 14) 14.6.4.1/1

- - , , , , , - . , .

f(CL) fnc<CL>, (VS, gcc, clang) . ?

+4
1

t of fnc , . . : 1- - , - .

, , POI ( ), ADL. struct CL void f(CL), POI, , .

struct CL , ADL, .

namespace NS {
    struct CL{};
    void f(CL){}
    //...
}

, ( )

, , , , ADL ( ++ 11) , , ADL ( ++ 11), ( , , ADL).

+7

Source: https://habr.com/ru/post/1613817/


All Articles