Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

7.9. Strong Using

Caution: The semantics of this extension are not fully defined. Users should refrain from using this extension as its semantics may change subtly over time. It is possible that this extension wil be removed in future versions of G++.

A using-directive with __attribute ((strong)) is stronger than a normal using-directive in two ways:

  • Templates from the used namespace can be specialized as though they were members of the using namespace.

  • The using namespace is considered an associated namespace of all templates in the used namespace for purposes of argument-dependent name lookup.

This is useful for composing a namespace transparently from implementation namespaces. For example:

namespace std {
  namespace debug {
    template <class T> struct A { };
  }
  using namespace debug __attribute ((__strong__));
  template <> struct A<int> { };   // ok to specialize

  template <class T> void f (A<T>);
}

int main()
{
  f (std::A<float>());             // lookup finds std::f
  f (std::A<int>());
}

 
 
  Published under the terms of the GNU General Public License Design by Interspire