Re: Emulate hash_map using map when necessary.
submitted. Thanks for prodding me into fixing this. :) On Fri, Sep 19, 2008 at 6:41 AM, <[EMAIL PROTECTED]> wrote: > You can submit it, the code is correct. > > > > Thank you. > > > > > > > > > -- > > *De :* Kenton Varda [mailto:[EMAIL PROTECTED] > *Envoyé :* 18 septembre 2008 17:13 > *À :* [EMAIL PROTECTED]; Choinière, Vincent; protobuf@googlegroups.com > *Objet :* Re: Emulate hash_map using map when necessary. > > > > Any comments on the code? If not, I'll go ahead and submit it. > > On Thu, Sep 18, 2008 at 1:59 PM, <[EMAIL PROTECTED]> wrote: > > Yes, is working. > > ==> Test ok on Tru64 (with some other changed in the code for the > compiler) > ==> Test ok on Windows Visual Studio 2005 > > Issue 5682 can be ignored... > > > > http://codereview.appspot.com/5683 > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---
RE: Emulate hash_map using map when necessary.
You can submit it, the code is correct. Thank you. De : Kenton Varda [mailto:[EMAIL PROTECTED] Envoyé : 18 septembre 2008 17:13 À : [EMAIL PROTECTED]; Choinière, Vincent; protobuf@googlegroups.com Objet : Re: Emulate hash_map using map when necessary. Any comments on the code? If not, I'll go ahead and submit it. On Thu, Sep 18, 2008 at 1:59 PM, <[EMAIL PROTECTED]> wrote: Yes, is working. ==> Test ok on Tru64 (with some other changed in the code for the compiler) ==> Test ok on Windows Visual Studio 2005 Issue 5682 can be ignored... http://codereview.appspot.com/5683 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---
Re: Emulate hash_map using map when necessary.
Any comments on the code? If not, I'll go ahead and submit it. On Thu, Sep 18, 2008 at 1:59 PM, <[EMAIL PROTECTED]> wrote: > Yes, is working. > > ==> Test ok on Tru64 (with some other changed in the code for the > compiler) > ==> Test ok on Windows Visual Studio 2005 > > Issue 5682 can be ignored... > > > http://codereview.appspot.com/5683 > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---
Re: Emulate hash_map using map when necessary.
Yes, is working. ==> Test ok on Tru64 (with some other changed in the code for the compiler) ==> Test ok on Windows Visual Studio 2005 Issue 5682 can be ignored... http://codereview.appspot.com/5683 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---
Emulate hash_map using map when necessary.
Reviewers: choiniere.vincent, Description: Hi Vincent, After looking at your change I came up with an alternative version. Can you try this out and let me know if it works for you? Please review this at http://codereview.appspot.com/5683 Affected files: src/google/protobuf/stubs/hash.h Index: src/google/protobuf/stubs/hash.h === --- src/google/protobuf/stubs/hash.h(revision 45) +++ src/google/protobuf/stubs/hash.h(working copy) @@ -29,17 +29,64 @@ #include HASH_MAP_H #include HASH_SET_H #else -// TODO(kenton): Deal with non-existence of hash_map somehow. Maybe emulate -// it with map? -#error "Your STL implementation lacks hash_map and/or hash_set." +#define MISSING_HASH +#include +#include #endif namespace google { namespace protobuf { -#ifdef _MSC_VER +#ifdef MISSING_HASH +// This system doesn't have hash_map or hash_set. Emulate them using map and +// set. + +// Make hash be the same as less. Note that everywhere where custom +// hash functions are defined in the protobuf code, they are also defined such +// that they can be used as "less" functions, which is required by MSVC anyway. template +struct hash { + // Dummy, just to make derivative hash functions compile. + int operator()(const Key& key) { +GOOGLE_LOG(FATAL) << "Should never be called."; +return 0; + } + + inline bool operator()(const Key& a, const Key& b) const { +return a < b; + } +}; + +// Make sure char* is compared by value. +template <> +struct hash { + // Dummy, just to make derivative hash functions compile. + int operator()(const char* key) { +GOOGLE_LOG(FATAL) << "Should never be called."; +return 0; + } + + inline bool operator()(const char* a, const char* b) const { +return strcmp(a, b) < 0; + } +}; + +template , + typename EqualKey = int > +class hash_map : public std::map { +}; + +template , + typename EqualKey = int > +class hash_set : public std::set { +}; + +#elif defined(_MSC_VER) + +template struct hash : public HASH_NAMESPACE::hash_compare { }; --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---