index.html: Add tip about namespace for extensions.
authorJonathan Wakely <redi@gcc.gnu.org>
Thu, 28 Nov 2002 19:15:04 +0000 (19:15 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 28 Nov 2002 19:15:04 +0000 (19:15 +0000)
2002-11-28  Jonathan Wakely  <redi@gcc.gnu.org>
* docs/html/faq/index.html: Add tip about namespace for extensions.

From-SVN: r59613

libstdc++-v3/ChangeLog
libstdc++-v3/docs/html/faq/index.html

index b18948e3f079e2ae68aa704363fcd9d22775d165..5efdd974f97b1abd2c2bd1c14b8cffde9db577e8 100644 (file)
@@ -1,3 +1,6 @@
+2002-11-28  Jonathan Wakely  <redi@gcc.gnu.org>
+       * docs/html/faq/index.html: Add tip about a namespace for extensions.
+
 2002-11-28  Paolo Carlini  <pcarlini@unitus.it>
             Nathan Myers  <ncm@cantrip.org>
 
index f7a9b0ac708a9e4d7a7aafe5387b398400571a25..f472bfc9dc615af18ea5d9ca9cca8529b2f43823 100644 (file)
@@ -877,6 +877,34 @@ http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
          that of other headers whose directories are not searched directly,
          e.g., <code>&lt;sys/stat.h&gt;</code>, <code>&lt;X11/Xlib.h&gt;</code>.
       </p>
+
+      <p>The extensions are no longer in the global or <code>std</code>
+         namespaces, instead they are declared in the <code>__gnu_cxx</code>
+         namespace. For maximum portability, consider defining a namespace
+         alias to use to talk about extensions, e.g.:
+      </p>
+      <pre>
+      #ifdef __GNUC__
+      #if __GNUC__ &lt; 3
+        #include &lt;hash_map.h&gt;
+        namespace Sgi { using ::hash_map; }; // inherit globals
+      #else
+        #include &lt;ext/hash_map&gt;
+        #if __GNUC_MINOR__ == 0
+          namespace Sgi = std;               // GCC 3.0
+        #else
+          namespace Sgi = ::__gnu_cxx;       // GCC 3.1 and later
+        #endif
+      #endif
+      #else      // ...  there are other compilers, right?
+        namespace Sgi = std;
+      #endif
+
+      Sgi::hash_map&lt;int,int&gt; my_map; </pre>
+      <p>This is a bit cleaner than defining typedefs for all the
+         instantiations you might need.
+      </p>
+
       <p>Extensions to the library have
          <a href="../ext/howto.html">their own page</a>.
       </p>