Type dependent template name

nipun510
#include <iostream>

template<typename T>
void f(T x)
{
   g(x); // g is a dependent name
};

void g(int a)
{
   std::cout << a;
}

int main()
{
   int a = 12;
   f(a);
}

//this should be point of declaration for f<int>    

Above code gives compilation error "‘g’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation".

Since g is a dependent name, its name should be visible at the time of instantiation. Please tell what am I missing?

T.C.

The lookup in the instantiation context only considers candidates found by argument-dependent lookup. Since int has no associated namespaces or classes, that lookup finds nothing.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Is this really a dependent template name?

Can I get a const dependent name from a const type template argument when instantiating a template?

Use template from dependent type

Type definitions dependent on template parameters

deduce type of variable dependent on template function type

Is it a defect in the standard about dependent name resolution for template

Why dependent template name accepted without keyword?

Dependent name lookup in base class template

CRTP with dependent type, type name lookup

Type-dependent constant in template function

Type definition should be dependent on template parameters

Template function dependent on non-type parameter

How to specialize template on arbitrary dependent type

Type trait dependent specialization of template function

How to define a type dependent on template parameters

Non-type template parameter dependent on a default template type parameter

Name lookup on template base classes in non-dependent name scenarios

Template dependent name resolution should not find declarations with no linkage?

Why is template function of data member a dependent name only when qualifying with "this"?

How to create dependent tinymce textarea according to the selection of email template name?

refer to a non-dependent name without specifying template parameter

Why is initialization of a constant dependent type in a template parameter list disallowed by the standard?

Why can't I specialize with a nullptr template parameter on a dependent type?

Is a function type dependent if it depends only on its own template parameters?

Is a c++11 variadic function template overload with a dependent type ambiguous?

Overloading operator "<<" in C++ with template-dependent type

How can a type alias with using specify a template template argument dependent on a template argument?

Confused about C++ nested dependent type name

C++17 dependent name is not a type, works in C++14

TOP Ranking

HotTag

Archive