diff options
Diffstat (limited to 'src/google/protobuf/map_field_inl.h')
-rw-r--r-- | src/google/protobuf/map_field_inl.h | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/google/protobuf/map_field_inl.h b/src/google/protobuf/map_field_inl.h index d0517792..0e78342c 100644 --- a/src/google/protobuf/map_field_inl.h +++ b/src/google/protobuf/map_field_inl.h @@ -38,6 +38,10 @@ #include <google/protobuf/map_field.h> #include <google/protobuf/map_type_handler.h> +#ifdef SWIG +#error "You cannot SWIG proto headers" +#endif + namespace google { namespace protobuf { namespace internal { @@ -65,7 +69,7 @@ inline bool UnwrapMapKey<bool>(const MapKey& map_key) { return map_key.GetBoolValue(); } template<> -inline string UnwrapMapKey<string>(const MapKey& map_key) { +inline std::string UnwrapMapKey<std::string>(const MapKey& map_key) { return map_key.GetStringValue(); } @@ -93,7 +97,7 @@ inline void SetMapKey<bool>(MapKey* map_key, const bool& value) { map_key->SetBoolValue(value); } template<> -inline void SetMapKey<string>(MapKey* map_key, const string& value) { +inline void SetMapKey<std::string>(MapKey* map_key, const std::string& value) { map_key->SetStringValue(value); } @@ -249,13 +253,14 @@ template <typename Derived, typename Key, typename T, WireFormatLite::FieldType kKeyFieldType, WireFormatLite::FieldType kValueFieldType, int default_enum_value> void MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, - default_enum_value>::Swap(MapField* other) { - std::swap(this->MapFieldBase::repeated_field_, other->repeated_field_); - impl_.Swap(&other->impl_); + default_enum_value>::Swap(MapFieldBase* other) { + MapField* other_field = down_cast<MapField*>(other); + std::swap(this->MapFieldBase::repeated_field_, other_field->repeated_field_); + impl_.Swap(&other_field->impl_); // a relaxed swap of the atomic - auto other_state = other->state_.load(std::memory_order_relaxed); + auto other_state = other_field->state_.load(std::memory_order_relaxed); auto this_state = this->MapFieldBase::state_.load(std::memory_order_relaxed); - other->state_.store(this_state, std::memory_order_relaxed); + other_field->state_.store(this_state, std::memory_order_relaxed); this->MapFieldBase::state_.store(other_state, std::memory_order_relaxed); } @@ -338,6 +343,6 @@ size_t MapField<Derived, Key, T, kKeyFieldType, kValueFieldType, } } // namespace internal } // namespace protobuf - } // namespace google + #endif // GOOGLE_PROTOBUF_MAP_FIELD_INL_H__ |