Note that there are some explanatory texts on larger screens.

plurals
  1. POScoped using-directive within a struct/class declaration?
    primarykey
    data
    text
    <p>I find that my C++ <em>header files</em> are quite hard to read (and really tedious to type) with all the fully-qualified types (which goes as deep as 4 nested namespaces). This is the question (all the answers give messy alternatives to implementing it, but that's <em>not</em> the question): <strong><em>Is there a strong reason against introducing scoped using-directive in structs and classes in the C++ language</em></strong> (while it's permissible to have scoped using-declaration in functions)?</p> <p>e.g.</p> <pre><code>class Foo : public Bar { using namespace System; using namespace System::Network; using namespace System::Network::Win32::Sockets; using Bar::MemberFunc; // no conflict with this // e.g. of how messy my header files are without scoped using-directive void FooBar(System::Network::Win32::Sockets::Handle handle, System::Network::Win32::Sockets::Error&amp; error /*, more fully-qualified param declarations... */); }; </code></pre> <p>Since <code>namespace</code> is a keyword, I would've thought it's distinct enough to cause no conflict with the scoped using declaration such as <code>Bar::MemberFunc</code>.</p> <p>EDIT: Read the question carefully ---> I've bolded it. Reminder: we're <strong>not</strong> discussing how to improve readability of the example here. Suggesting how scoped using-directive could be implemented (i.e. by means of adding keywords / constructs etc.) in the C++ language is <em>NOT</em> an answer (if you could find an elegant way to implement this using existing C++ language standards, then it would of course be an answer)!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload