This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: sgi extensions
On Fri, Nov 22, 2002 at 02:44:13PM -0500, Phil Edwards wrote:
> On Fri, Nov 22, 2002 at 11:42:45AM -0800, Tim Arland wrote:
> >
> > Are there namespace tricks I need to do to get at the sgi extensions?
> > simply using #include <ext/hash_map> doesn't seem to be doing the trick
> > as it claims hash_map is undeclared.
>
> They're in the __gnu_cxx namespace.
For maximum portability, consider defining a namespace alias to use
to talk about extensions. E.g.
#ifdef __GNUC__
#if __GNUC__ < 3
#include <hash_map.h>
namespace Sgi { using ::hash_map; }; // inherit globals
#else
#include <ext/hash_map>
namespace Sgi = ::__gnu_cxx;
#endif
#else // ... there are other compilers, right?
namespace Sgi = std;
#endif
Sgi::hash_map<int,int> my_map;
This is a bit cleaner than defining typedefs for all the instantiations
you might need. (It's a pity you can't say "namespace Sgi = ::;".)
Phil, you might suggest something like this in the docs.
Nathan Myers
ncm-nospam@cantrip.org