diff options
author | Bo Yang <teboring@google.com> | 2015-08-23 10:45:14 -0700 |
---|---|---|
committer | Bo Yang <teboring@google.com> | 2015-08-25 17:58:48 -0700 |
commit | ff7bdad231d037802fd457ee4fd65e0291d366d7 (patch) | |
tree | 12f437b32201cdbbfade6d63193e15483640716d /src/google/protobuf/map.h | |
parent | 839b180dbae98adf6caa54d0fb87b8d0a43081dc (diff) |
Fix bugs on windows
Diffstat (limited to 'src/google/protobuf/map.h')
-rw-r--r-- | src/google/protobuf/map.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index c43df13e..8b61573d 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -592,7 +592,7 @@ class Map { typedef MapAllocator<std::pair<const Key, MapPair<Key, T>*> > Allocator; // Iterators - class LIBPROTOBUF_EXPORT const_iterator + class const_iterator : public std::iterator<std::forward_iterator_tag, value_type, ptrdiff_t, const value_type*, const value_type&> { typedef typename hash_map<Key, value_type*, hash<Key>, equal_to<Key>, @@ -853,6 +853,29 @@ struct hash<google::protobuf::MapKey> { return 0; } } + bool + operator()(const google::protobuf::MapKey& map_key1, + const google::protobuf::MapKey& map_key2) const { + switch (map_key1.type()) { +#define COMPARE_CPPTYPE(CPPTYPE, CPPTYPE_METHOD) \ + case google::protobuf::FieldDescriptor::CPPTYPE_##CPPTYPE: \ + return map_key1.Get##CPPTYPE_METHOD##Value() < \ + map_key2.Get##CPPTYPE_METHOD##Value(); + COMPARE_CPPTYPE(STRING, String) + COMPARE_CPPTYPE(INT64, Int64) + COMPARE_CPPTYPE(INT32, Int32) + COMPARE_CPPTYPE(UINT64, UInt64) + COMPARE_CPPTYPE(UINT32, UInt32) + COMPARE_CPPTYPE(BOOL, Bool) +#undef COMPARE_CPPTYPE + case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE: + case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT: + case google::protobuf::FieldDescriptor::CPPTYPE_ENUM: + case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: + GOOGLE_LOG(FATAL) << "Can't get here."; + return true; + } + } }; GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END |