Commit 7fb9ae9d authored by kenton@google.com's avatar kenton@google.com

Make sure to quality calls to std::swap. Otherwise, if a google::swap() exists…

Make sure to quality calls to std::swap.  Otherwise, if a google::swap() exists (e.g. because the user is using our own dense_hash_map implementation) it will be chosen instead, leading to a compile error.
parent b26684a9
...@@ -775,8 +775,8 @@ TEST_F(CommandLineInterfaceTest, WriteTransitiveDescriptorSet) { ...@@ -775,8 +775,8 @@ TEST_F(CommandLineInterfaceTest, WriteTransitiveDescriptorSet) {
if (HasFatalFailure()) return; if (HasFatalFailure()) return;
ASSERT_EQ(2, descriptor_set.file_size()); ASSERT_EQ(2, descriptor_set.file_size());
if (descriptor_set.file(0).name() == "bar.proto") { if (descriptor_set.file(0).name() == "bar.proto") {
swap(descriptor_set.mutable_file()->mutable_data()[0], std::swap(descriptor_set.mutable_file()->mutable_data()[0],
descriptor_set.mutable_file()->mutable_data()[1]); descriptor_set.mutable_file()->mutable_data()[1]);
} }
EXPECT_EQ("foo.proto", descriptor_set.file(0).name()); EXPECT_EQ("foo.proto", descriptor_set.file(0).name());
EXPECT_EQ("bar.proto", descriptor_set.file(1).name()); EXPECT_EQ("bar.proto", descriptor_set.file(1).name());
......
...@@ -324,7 +324,7 @@ void GeneratedMessageReflection::Swap( ...@@ -324,7 +324,7 @@ void GeneratedMessageReflection::Swap(
int has_bits_size = (descriptor_->field_count() + 31) / 32; int has_bits_size = (descriptor_->field_count() + 31) / 32;
for (int i = 0; i < has_bits_size; i++) { for (int i = 0; i < has_bits_size; i++) {
swap(has_bits1[i], has_bits2[i]); std::swap(has_bits1[i], has_bits2[i]);
} }
for (int i = 0; i < descriptor_->field_count(); i++) { for (int i = 0; i < descriptor_->field_count(); i++) {
...@@ -360,8 +360,8 @@ void GeneratedMessageReflection::Swap( ...@@ -360,8 +360,8 @@ void GeneratedMessageReflection::Swap(
switch (field->cpp_type()) { switch (field->cpp_type()) {
#define SWAP_VALUES(CPPTYPE, TYPE) \ #define SWAP_VALUES(CPPTYPE, TYPE) \
case FieldDescriptor::CPPTYPE_##CPPTYPE: \ case FieldDescriptor::CPPTYPE_##CPPTYPE: \
swap(*MutableRaw<TYPE>(message1, field), \ std::swap(*MutableRaw<TYPE>(message1, field), \
*MutableRaw<TYPE>(message2, field)); \ *MutableRaw<TYPE>(message2, field)); \
break; break;
SWAP_VALUES(INT32 , int32 ); SWAP_VALUES(INT32 , int32 );
...@@ -376,8 +376,8 @@ void GeneratedMessageReflection::Swap( ...@@ -376,8 +376,8 @@ void GeneratedMessageReflection::Swap(
#undef SWAP_VALUES #undef SWAP_VALUES
case FieldDescriptor::CPPTYPE_STRING: case FieldDescriptor::CPPTYPE_STRING:
swap(*MutableRaw<string*>(message1, field), std::swap(*MutableRaw<string*>(message1, field),
*MutableRaw<string*>(message2, field)); *MutableRaw<string*>(message2, field));
break; break;
default: default:
......
...@@ -491,7 +491,7 @@ void RepeatedField<Element>::Swap(RepeatedField* other) { ...@@ -491,7 +491,7 @@ void RepeatedField<Element>::Swap(RepeatedField* other) {
template <typename Element> template <typename Element>
void RepeatedField<Element>::SwapElements(int index1, int index2) { void RepeatedField<Element>::SwapElements(int index1, int index2) {
swap(elements_[index1], elements_[index2]); std::swap(elements_[index1], elements_[index2]);
} }
template <typename Element> template <typename Element>
...@@ -627,7 +627,7 @@ RepeatedPtrFieldBase::data() const { ...@@ -627,7 +627,7 @@ RepeatedPtrFieldBase::data() const {
} }
inline void RepeatedPtrFieldBase::SwapElements(int index1, int index2) { inline void RepeatedPtrFieldBase::SwapElements(int index1, int index2) {
swap(elements_[index1], elements_[index2]); std::swap(elements_[index1], elements_[index2]);
} }
template <typename TypeHandler> template <typename TypeHandler>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment