G++ 3.3.1 Specialization bug?

Wu Yongwei adah@netstd.com
Tue Sep 9 07:23:00 GMT 2003


Sorry for this really, really terribly late message.  I had been very 
busy.  The "problem" I reported is one that I found when hacking the source.

I now fully understand that it is not a "bug".  Thank Jonathan Wakely 
for pointing to me why the code worked for GCC 2.95.  Thank Kirill 
Smelkov and Gabriel Dos Reis for kindly commenting on the issue.  And I 
now accept the fact the namespace __gnu_cxx cannot be fully transparent, 
and at least a macro should be used when specializing for hash.

My middle layer finally goes like this:

#ifndef SGI_HASH_NAMESPACE

# if !defined(HAS_STLPORT) && defined(__GNUC__) && __GNUC__ >= 3
#   if __GNUC__ == 3 && __GNUC_MINOR__ == 0         // GCC 3.0
#     define SGI_HASH_NAMESPACE std
#   else                                            // GCC 3.1 or later
#     define SGI_HASH_NAMESPACE __gnu_cxx
#   endif
# else                                              // Other compilers
#   define SGI_HASH_NAMESPACE std
# endif

#endif // SGI_HASH_NAMESPACE

# if !defined(HAS_STLPORT) && defined(__GNUC__) && __GNUC__ >= 3
#   include <ext/hash_map>
# else
#   include <hash_map>
# endif
# if defined(__GNUC__) && __GNUC__ < 3
     namespace sgi { using SGI_HASH_NAMESPACE::hash_map; };
# else
     namespace sgi = SGI_HASH_NAMESPACE;
# endif

When specializing for hash, SGI_HASH_NAMESPACE must be used.  In all 
other cases it is enough to use just "sgi::".

Best regards,

Wu Yongwei




More information about the Libstdc++ mailing list