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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:52:58+00:00 2026-06-18T04:52:58+00:00

Possible Duplicate: Using std Namespace I was just wondering if there was some reason

  • 0

Possible Duplicate:
Using std Namespace

I was just wondering if there was some reason to include std:: in some operations, like std::sort() for example. Is it because of possible overloading?

  • 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-06-18T04:52:59+00:00Added an answer on June 18, 2026 at 4:52 am

    Apart from the usually well known reasons of polluting the current namespace with unnecessary symbol names and readability there is a subtle another reasoning.

    Consider the example of std::swap,it is an standard library algorithm to swap two values. With Koenig algorithm/ADL one would have to be cautious while using this algorithm because:

    std::swap(obj1,obj2);    
    

    may not show the same behavior as:

    using std::swap;
    swap(obj1, obj2);
    

    With ADL, which version of swap function gets called would depend on the namespace of the arguments passed to it.
    If there exists an namespace A and if A::obj1, A::obj2 & A::swap() exist then the second example will result in a call to A::swap() which might not be what the user wanted.

    Further, if for some reason both:
    A::swap(A::MyClass&, A::MyClass&) and std::swap(A::MyClass&, A::MyClass&) are defined, then the first example will call std::swap(A::MyClass&, A::MyClass&) but the second will not compile because swap(obj1, obj2) would be ambiguous.

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

Sidebar

Related Questions

Possible Duplicate: Copy Constructor is not invoked # include <iostream> using namespace std; class
Possible Duplicate: Using printf function #include<iostream> using namespace std; int main() { long long
Possible Duplicate: Struct Padding The program is as below: #include <iostream> using namespace std;
Possible Duplicate: Pointer to local variable #include <iostream> using namespace std; char* func(); int
Possible Duplicate: std::endl is of unknown type when overloading operator<< #include <iostream> using namespace
Possible Duplicate: Calling class method through NULL class pointer #include <iostream> using namespace std;
Possible Duplicate: Why is ‘using namespace std;’ considered a bad practice in C++? I've
Possible Duplicate: Virtual Functions Object Slicing let's consider: #include <vector> #include <iostream> using namespace
Possible Duplicate: Ordering of using namespace std; and includes? I heard that it is
Possible Duplicate: Why is 'using namespace std;' considered a bad practice in C++? I

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.