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

  • Home
  • SEARCH
  • 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 7443135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:17:03+00:00 2026-05-29T11:17:03+00:00

How do I tell whether I should use my_type bar; using some_namespace::foo; foo(bar); instead

  • 0

How do I tell whether I should use

my_type bar;
using some_namespace::foo;
foo(bar);

instead of

some_namespace::foo(bar);

when calling my function foo (that is not within my immediate scope)? Is there a generic “rule” for figuring out whether you should use ADL or not? Which one should I use “by default”?

  • 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-29T11:17:04+00:00Added an answer on May 29, 2026 at 11:17 am

    That is not ADL. In both of your examples, foo is found via normal lookup. An example using ADL would be as follows:

    namespace ns {
        class A { };
        void f(A) { };
    }
    
    int main() {
        f(A());
    }
    

    Here, f is not found via normal lookup, but it is found via argument-dependent lookup (because it is in namespace ns alongside A). In any case…

    Avoid ADL wherever possible.

    ADL is beneficial in certain, specific scenarios, for example for operator overloading and for the swappable concept. However, it should be used sparingly, as it leads to bizarre, unexpected behavior in many other cases.

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

Sidebar

Related Questions

Does anybody know offhand the way to tell whether I'm being called statically (Classname::function)
I'd like to be able to tell whether or not an assembly is the
Please tell me whether it is possible to use both SimpleUrlHandlerMapping and AnnotationMapping in
Ok firstly, this is not a discussion on whether I should be catering for
First I should tell you that ive little knowledge of Objective C or C#.So
How can I tell whether a circle and a rectangle intersect in 2D Euclidean
I want to tell whether two tarball files contain identical files, in terms of
How can you tell whether the device is oriented vertically (portrait) or horizontally (landscape)?
Is there a way I can tell whether stderr is outputting to a file
Is there a way in JavaScript for me to tell whether a resource is

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.