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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:10:22+00:00 2026-05-28T04:10:22+00:00

When using a using namespace statement inside an anonymous namespace bring the namespace used

  • 0

When using a using namespace statement inside an anonymous namespace bring the namespace used in to the file scope? Eg:

namespace foo
{
    int f() { return 1; }
}
namespace
{
    using namespace foo;
}
int a()
{
    return f(); // Will this compile?
}
  • 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-28T04:10:22+00:00Added an answer on May 28, 2026 at 4:10 am

    According to 7.3.4 [namespace.udir] paragraph 4 a namespace directive is transitive:

    For unqualified lookup nominates a second namespace that itself contains using-directives, the effect is as if the using-directives from the second namespace also appeared in the first.

    … and according to 7.3.1.1 [namespace.unnamed] paragraph 1 there is kind of an implicit using directive for the unnamed namespace:

    An unnamed-namespace-definition behaves as if it were replaced by

    inline namespace unique { /* empty body */ }
    using namespace unique ;
    namespace unique { namespace-body }

    where inline appears if and only if it appears in the unnamed-namespace-definition, all occurrences of unique in a translation unit are replaced by the same identifier, and this identifier differs from all other identifiers in the entire program.

    Thus, the answer is “yes, this is supposed to compile” (and it does with all C++ compilers I tried it with).

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

Sidebar

Related Questions

I have this code #include <iostream> using namespace std; int main(int argc,char **argv) {
DUPE: Should 'using' statements be inside or outside the namespace? If I add a
using namespace std; class A { public: A() {} ~A() {} map<int, string*>& getMap()
I've recently been working with code that looks like this: using namespace std; class
#include <iostream> using namespace std; int main() { double u = 0; double w
#include <iostream> #include <fstream> using namespace std; class binaryOperators { public: int i; binaryOperators
The related default StyleCop rules are: Place using statements inside namespace . Sort using
Why are the using statements inside of the namespace in Silverlight 4/VS 2010 auto-generated
Given the following code: #include <iostream> using namespace std; class CRectangle { public: int
With #include <iostream> using namespace std; int a = 1; int main() { int

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.