Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6573153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:05:46+00:00 2026-05-25T15:05:46+00:00

Possible Duplicate: Why doesn't ADL find function templates? Calling get does not seem to

  • 0

Possible Duplicate:
Why doesn't ADL find function templates?

Calling get does not seem to invoke argument dependent lookup:

auto t = std::make_tuple(false, false, true);
bool a = get<0>(t);        // error
bool b = std::get<0>(t);   // okay

g++ 4.6.0 says:

error: 'get' was not declared in this scope

Visual Studio 2010 says:

error C2065: 'get': undeclared identifier

Why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:05:47+00:00Added an answer on May 25, 2026 at 3:05 pm

    It’s because you attempt to explicitly instantiate get function template, by providing 0 as template argument. In case of templates, ADL works if a function template with that name is visible at the point of the call. This visible function template only helps triggering ADL (it may not be used actually) and then, a best matching can be found in other namespaces.

    Note that the function template which triggers (or enable) ADL, need not to have definition:

    namespace M
    {
        struct S{};
    
        template<int N, typename T>
        void get(T) {}     
    }
    
    namespace N
    {
       template<typename T>
       void get(T); //no need to provide definition
                    // as far as enabling ADL is concerned!
    } 
    
    void f(M::S s)
    {
       get<0>(s); //doesn't work - name `get` is not visible here 
    }
    
    void g(M::S s)
    {
       using N::get; //enable ADL
       get<0>(s); //calls M::get
    }
    

    In g(), the name N::get triggers ADL when calling get<0>(s).

    Demo : http://ideone.com/83WOW


    C++ (2003) section §14.8.1/6 reads,

    [Note: For simple function names, argument dependent lookup (3.4.2) applies even when the function name is not visible within the scope of the call. This is because the call still has the syntactic form of a function call (3.4.1). But when a function template with explicit template arguments is used, the call does not have the correct syntactic form unless there is a function template with that name visible at the point of the call. If no such name is visible, the call is not syntactically well-formed and argument-dependent lookup does not apply. If some such name is visible, argument dependent lookup applies and additional function templates may be found in other namespaces.

    [Example:

    namespace A {
         struct B { };
         template<int X> void f(B);
    }
    namespace C {
         template<class T> void f(T t);
    }
    void g(A::B b) {
         f<3>(b);    //ill-formed: not a function call
         A::f<3>(b); //well-formed
         C::f<3>(b); //ill-formed; argument dependent lookup
                     // applies only to unqualified names
    
        using C::f;
         f<3>(b); //well-formed because C::f is visible; then
                  // A::f is found by argument dependent lookup
    }
    

    —end example] —end note]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Why does C# not provide the C++ style ‘friend’ keyword? I'd like
Possible Duplicate: C# : Why doesn't 'ref' and 'out' support polymorphism? I can't seem
Possible Duplicate: Python: Adding element to list while iterating This doesn't seem to work,
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: What does map(&:name) mean in Ruby? I was watching a railscast and
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: JavaScript: var functionName = function() {} vs function functionName() {} What's the
Possible Duplicate: Why doesn't the weakref work on this bound method? I'm using weakrefs
Possible Duplicate: Why doesn't System.out.println work? (in Android) I want to print something into
Possible Duplicate: Why doesn't the CLR always call value type constructors Found next code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.