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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:02:03+00:00 2026-05-18T10:02:03+00:00

Header files with declarations like this: void FooBar(System::Network::Win32::Sockets::Handle handle, System::Network::Win32::Sockets::Error& error /*, more fully-qualified

  • 0

Header files with declarations like this:

void FooBar(System::Network::Win32::Sockets::Handle handle, System::Network::Win32::Sockets::Error& error /*, more fully-qualified param
declarations... */);

are common in certain frameworks. And using declarations, which could mitigate
this problem, are generally not considered kosher to use in header files
because they can effect the name lookup rules for header files that are
included later. typedefs inside a class that are declared private clutter up
the class’ namespace and the namespace of classes derived from it.

Here is a proposed solution:

using {
   // A 'using' block is a sort of way to fence names in.  The only names
   // that escape the confines of a using block are names that are not
   // aliases for other things, not even for things that don't have names
   // of their own.  These are things like the declarations for new
   // classes, enums, structs, global functions or global variables.
   // New, non-alias names will be treated as if they were declared in
   // the scope in which the 'using' block appeared.

   using namespace ::std;
   using ::mynamespace::mytype_t;
   namespace mn = ::mynamespace;
   using ::mynamespace::myfunc;

   class AClass {
     public:
      AClass(const string &st, mytype_t me) : st_(st), me_(me) {
         myfunc(&me_);
      }

     private:
      const string st_;  // string will refer to ::std::string
      mn::mytype_t me_;
   };
// The effects of all typedefs, using declarations, and namespace
// aliases that were introduced at the level of this block go away
// here.  typedefs and using declarations inside of nested classes
// or namespace declarations do not go away.
} // end using.

// Legal because AClass is treated as having been declared in this
// scope.
AClass a("Fred", ::mynamespace::mytype_t(5));

// Not legal, alias mn no longer exists.
AClass b("Fred", mn::mytype_t);

// Not legal, the unqualified name myfunc no longer exists.
AClass c("Fred", myfunc(::mynamespace::mytype_t(5));

In Java and Python individual files are treated in a special way. You can have import declarations that inject names from other namespaces into the file. These names will (well, not exactly with Python, but it’s too complicated to explain here) only be visible within that file.

I think C++ needs a similar construct. The existence of the preprocessor, the #include directive, and the C++ concept of a translation unit make the implicit scoping of imported names problematic. So some I think some mechanism for explicitly scoping such temporary aliases is needed.

What problems do you foresee with this idea? If there are no problems, or the problems are very small and fixable, how would I go about submitting it as a proposal to the standards committee?

  • 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-18T10:02:03+00:00Added an answer on May 18, 2026 at 10:02 am

    The ISO/IEC JTC1/SC22/WG21 (aka C++) standards committee is close to finishing the C++0x standard; you have essentially no chance of getting this proposal into the C++0x standard.

    For any proposal, you have to present the motivation for the feature, explaining why this should be added to the standard instead of the 50 other proposals contending for the privilege. (See Stroustrup’s explanation in D&E – ‘Design and Evolution of C++’.)

    You also benefit from having an implementation in place, which is available and used, so people have hands-on experience of the feature at work. While it remains abstract and unimplemented, you run the risk of repeating the export fiasco, and the committee tries to avoid repeats of that. One advantage of this is that it helps build your constituency of people who are interested in using your feature. If you can’t build such a constituency, maybe your proposal isn’t worthy of inclusion in the standard.

    What you’ve given here might be an interesting start, but it is not yet anywhere near what would be needed to get to a standard proposal. Take a look at the documents on the Open Standards web site. Consider whether you have the resources at your disposal to take this forward. The chances are that you do not, I’m sorry to say.

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

Sidebar

Related Questions

Based on the response to this question: Why does C++ have header files and
On a Unix system, where does gcc look for header files? I spent a
In my C++ header files I try to use forward declarations (class MyClass;) instead
Why does C++ have header files and .cpp files?
I have a couple of header files, which boil down to: tree.h: #include element.h
Suppose I have #define foo in various header files. It may expand to some
I have to include many header files, which are in different sub-directories. Is there
I'm trying to create proper header files which don't include too many other files
Consider the following example. It consists of two header files, declaring two different namespaces:
Is there a decent way with static HTML/XHTML to create common header/footer files to

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.