This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: G++ 3.3.1 Specialization bug?


On Sat, Aug 30, 2003 at 12:53:26PM +0800, Wu Yongwei wrote:
> #include <stddef.h>

#include <cstddef>

> #if __GNUC__ == 3 && __GNUC_MINOR__ > 0
> #include <ext/hash_map>
> namespace sgi {
>     using __gnu_cxx::hash;
>     using __gnu_cxx::hash_map;
> }

#define SGI_HASH_NAMESPACE __gnu_cxx

> #else
> #include <hash_map>
> namespace sgi {
>     using std::hash;
>     using std::hash_map;
> }

#define SGI_HASH_NAMESPACE std

> #endif

or just

namespace sgi {
    using SGI_HASH_NAMESPACE::hash;
    using SGI_HASH_NAMESPACE::hash_map;
}

once.

> 
> struct my_obj {
>     int _value;
>     my_obj(int v) : _value(v) {}
> };
> 
> namespace sgi {

namespace SGI_HASH_NAMESPACE {

>     template <> struct hash<my_obj> {
>         size_t operator()(const my_obj& r) {
>             return r._value;
>         }
>     };
> }
> 
> int main()
> {
>     sgi::hash_map<my_obj, int> a;
> }
> 
> This is really making life difficult when hash_map support is wanted.
> 
> Any ideas?

-- 
Carlo Wood <carlo@alinoe.com>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]