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 6858093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:06:51+00:00 2026-05-27T02:06:51+00:00

I have two strange cases where it seems like code should compile, but it

  • 0

I have two strange cases where it seems like code should compile, but it doesn’t. To start, consider the code below, which compiles successfully:

struct A
{
    template <class T>
    void member_func(T t)
    {
        global_func(t);
    }
};

int main()
{
}

But if I fully-qualify global_func by prefixing with “::”, it doesn’t compile with error “‘global_func’ was not declared in this scope”:

struct A
{
    template <class T>
    void member_func(T t)
    {
        ::global_func(t);
    }
};

int main()
{
}

Also, if I try to pass global_func to boost::bind, it doesn’t compile (same error):

#include <boost/bind.hpp>

class A
{
    template <class T>
    void member_func(T t)
    {
        boost::bind(global_func)(t);
    }
};

int main()
{
}

Why doesn’t it compile in these cases? It seems like the member_func() template method isn’t instantiated, so it shouldn’t find the missing function error.

  • 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-27T02:06:52+00:00Added an answer on May 27, 2026 at 2:06 am

    In the first example global_func is a dependent name because it is an unqualified name used in a postfix () expression where the expression in parentheses depends on a template parameter. This means that lookup must be deferred until the point that the template is instantiated where the template parameter is known and ADL may have an effect.

    In the second example ::global_func is a qualified name so its lookup is not deferred and it must be looked up at the pointer where the template is defined.

    Similarly, in the expression boost::bind(global_func), global_func is not used in an expression which depends on the template parameter so, again, lookup is not deferred and a declaration must be visible at the point of definition of the member template.

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

Sidebar

Related Questions

This might sound like a strange question, but bear with me... I have a
I have a strange Hibernate behaviour in my program. I have two classes with
I have a very strange issue on my hands. I have two IIS websites
Why this two functions have the strange behaviour of when I click on thead,
I have a very strange behavior with Request.Form . Here are two IIS 7
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I'm noticing strange behavior. I have merchant and order tables and doing two selects
I have a strange issue: there is a SectionPart with composite, which is create
I've come across a strange render bug on iPhone OS 3.0... I have two
I am facing a strange error in cakephp2.0. I have created two layouts -

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.