www.digitalmars.com         C & C++   DMDScript  

c++.beta - [bug] boost hash problems

reply Daniel James <daniel_james fmail.co.uk> writes:
Hello,

I've just checked in some changes to get the boost hash library working 
on Digital Mars. With the lastest beta, the CVS version can now pass 
most of the tests (mainly due to the recent STLport changes I think). 
But there are a few minor failures left over due to a some bugs in the 
compiler.

First up, this fails to compile:

      template <class T> void hash_value(T* const&) {}

      int main()
      {
          int x = 10;
          hash_value(&x);
      }

Hopefully, it's obvious what should be happening there. In case you're
wondering why I'm doing such an odd thing, a plain pointer would cause
an ambiguous overload with the array overload of hash_value.

The second bug is that this also fails:

     template <class T> struct hash
     {
         void operator()(T const& val) const
         {
         }
     };

     int main()
     {
         hash<int[10]> x;
     }

Last one:

     struct custom {};
     void test(custom x) {}

     namespace foo
     {
         template <class T> void test(T*) {}

         void call_test(custom const& x)
         {
             return test(x);
         }
     }

Curiously, this works if custom and test(custom) are defined in a 
namespace - it only fails when they're in the global namespace.

None of these bugs are vitally important, I can mark up the test 
failures as expected. Basically it just means that you can't use the 
hash library for multi-dimensional arrays (ie. boost::hash<int[10][10]>) 
or custom types in the global namespace.

Daniel
May 07 2006
parent Walter Bright <newshound digitalmars.com> writes:
Thanks much!
May 07 2006