manpagez: man pages & more
info gcc
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.9 Namespace Association

Caution: The semantics of this extension are equivalent to C++ 2011 inline namespaces. Users should use inline namespaces instead as this extension will be removed in future versions of G++.

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

The used namespace must be nested within the using namespace so that normal unqualified lookup works properly.

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>());
}

This document was generated on October 19, 2013 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.