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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:13:04+00:00 2026-05-23T23:13:04+00:00

I have no intention of using this in real code. I promise. Does the

  • 0

I have no intention of using this in real code. I promise.

Does the standard guarantee that std namespace is going to be found when a function argument is of type container::iterator and container::iterator isn’t a typedef for a built-in type?

For example

#include <set>
#include <algorithm>
int main()
{
   std::set<int> s;
   find(s.begin(), s.end(), 0); //do I have a guarantee that std::find will be found?
}

In other words, can the iterator class be defined in such a namespace that std won’t be considered by ADL?

Thanks in advance.

  • 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-23T23:13:05+00:00Added an answer on May 23, 2026 at 11:13 pm

    I believe that the answer is no in the most general case, but yes for most practical implementations.

    According to the C++ ISO standard, §3.4.2/2, there is a notion of an “associated namespace” for an argument, which is defined in a way that includes

    If T is a class type (including unions), its associated classes are: the class itself; the class of which it is a
    member, if any
    ; and its direct and indirect base classes. Its associated namespaces are the namespaces
    in which its associated classes are defined.

    This suggests that if the iterator type is really a nested type inside of some container like std::set, then an associated namespace for that iterator in the call to find would be std, since std::set is an associated class and std is the namespace containing set. The standard then says that (§3.4.2/2a)

    If the ordinary unqualified lookup of the name finds the declaration of a class member function, the associated namespaces and classes are not considered. Otherwise the set of declarations found by the lookup of the function name is the union of the set of declarations found using ordinary unqualified lookup and the set
    of declarations found in the namespaces and classes associated with the argument types
    .

    This would mean that you would indeed find the find function in namespace std.

    However, this is not guaranteed to work in general. We also have from the spec (§3.4.2) that

    Typedef names and using-declarations used to specify the types do not contribute to this set.

    So, as you mentioned in your question, if the iterator type is some sort of typedef, this isn’t guaranteed to work correctly. But barring that, it appears that if you know that the type is not a typedef, it has to be in namespace std or nested in a class in namespace std and should get picked up for ADL. But don’t do it! 🙂

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

Sidebar

Related Questions

I have no intention of using My for anything in any of my projects.
I have a WCF service hosted in IIS. The intention is for clients to
I have been adding dependency injection to my code because it makes by code
I have some code which utilizes parameterized queries to prevent against injection, but I
Have just started using Google Chrome , and noticed in parts of our site,
I'm a long-time C++ programmer developing on Windows, and have been using Visual Studio
I'm currently using the mysqli php extension. Traditionally I have used mysqli_real_escape_string to escape
I'm developing an application using Wordpress as a CMS. I have a form with
I'm stuck with a service, which can't be found using it's explicit component name
I have ten text files (tab delimited, 200K rows). My intention is to seek

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.