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(t)
fnc
- - , , , , , - . , .
f(CL) fnc<CL>, (VS, gcc, clang) . ?
f(CL)
fnc<CL>
t of fnc , . . : 1- - , - .
t
, , POI ( ), ADL. struct CL void f(CL), POI, , .
CL
void f(CL)
struct CL , ADL, .
namespace NS { struct CL{}; void f(CL){} //... }
, ( )
, , , , ADL ( ++ 11) , , ADL ( ++ 11), ( , , ADL).
Source: https://habr.com/ru/post/1613817/More articles:Alternative solution for non-existent limit in JOIN ... WITH clause - javaHow to set permissions for Django / Mezzanine site administrators - pythonHow to display img from server in angularJS - javascriptanimation when you press the return button - androidFreeTDS returns strings with a null character - phpHow to get a link to an object stored in a list? - listWhy does the sonaqube gradle plugin create jacoco-general.exec files? - gradleGet the object to the memory address - memoryUsing Java BigDecimal still not solving correctly - javaSQL query str alchemy Query - pythonAll Articles