Skip to content

Commit 46656ed

Browse files
Breaking Change: proto2::Map::value_type changes to std::pair<const K, V>.
PiperOrigin-RevId: 503871374
1 parent dcbb00d commit 46656ed

File tree

4 files changed

+0
-58
lines changed

4 files changed

+0
-58
lines changed

src/google/protobuf/map.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -981,42 +981,9 @@ class KeyMapBase : public UntypedMapBase {
981981

982982
} // namespace internal
983983

984-
#ifdef PROTOBUF_FUTURE_MAP_PAIR_UPGRADE
985984
// This is the class for Map's internal value_type.
986985
template <typename Key, typename T>
987986
using MapPair = std::pair<const Key, T>;
988-
#else
989-
// This is the class for Map's internal value_type. Instead of using
990-
// std::pair as value_type, we use this class which provides us more control of
991-
// its process of construction and destruction.
992-
template <typename Key, typename T>
993-
struct PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG MapPair {
994-
using first_type = const Key;
995-
using second_type = T;
996-
997-
MapPair(const Key& other_first, const T& other_second)
998-
: first(other_first), second(other_second) {}
999-
explicit MapPair(const Key& other_first) : first(other_first), second() {}
1000-
explicit MapPair(Key&& other_first)
1001-
: first(std::move(other_first)), second() {}
1002-
MapPair(const MapPair& other) : first(other.first), second(other.second) {}
1003-
1004-
~MapPair() {}
1005-
1006-
// Implicitly convertible to std::pair of compatible types.
1007-
template <typename T1, typename T2>
1008-
operator std::pair<T1, T2>() const { // NOLINT(runtime/explicit)
1009-
return std::pair<T1, T2>(first, second);
1010-
}
1011-
1012-
const Key first;
1013-
T second;
1014-
1015-
private:
1016-
friend class Arena;
1017-
friend class Map<Key, T>;
1018-
};
1019-
#endif
1020987

1021988
// Map is an associative container type used to store protobuf map
1022989
// fields. Each Map instance may or may not use a different hash function, a

src/google/protobuf/map_test.inc

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -813,24 +813,6 @@ TEST_F(MapImplTest, Emplace) {
813813
m, UnorderedElementsAre(Pair(1, "one"), Pair(2, "two"), Pair(42, "aaa")));
814814
}
815815

816-
#ifndef PROTOBUF_FUTURE_MAP_PAIR_UPGRADE
817-
818-
TEST_F(MapImplTest, EmplaceKeyOnly) {
819-
using ::testing::Pair;
820-
using ::testing::UnorderedElementsAre;
821-
822-
Map<int32_t, std::string> m;
823-
824-
m.emplace(1);
825-
EXPECT_EQ(m.size(), 1);
826-
827-
const int32_t key = 42;
828-
m.emplace(key);
829-
EXPECT_THAT(m, UnorderedElementsAre(Pair(1, ""), Pair(42, "")));
830-
}
831-
832-
#else
833-
834816
TEST_F(MapImplTest, ValueTypeHasMoveConstructor) {
835817
using vt = typename Map<ConstructorTag, ConstructorTag>::value_type;
836818
ConstructorTag l, r;
@@ -841,8 +823,6 @@ TEST_F(MapImplTest, ValueTypeHasMoveConstructor) {
841823
EXPECT_EQ(pair.second.invoked_constructor, ConstructorType::kMove);
842824
}
843825

844-
#endif // !PROTOBUF_FUTURE_MAP_PAIR_UPGRADE
845-
846826
TEST_F(MapImplTest, TryEmplaceExisting) {
847827
Map<int32_t, CountedInstance> m;
848828

src/google/protobuf/port_def.inc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,6 @@ static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and
204204

205205
#ifdef PROTOBUF_FUTURE_BREAKING_CHANGES
206206

207-
// Used to upgrade google::protobuf::MapPair<K, V> to std::pair<const K, V>.
208-
// Owner: mordberg@
209-
#define PROTOBUF_FUTURE_MAP_PAIR_UPGRADE 1
210-
211207
// Used to remove the manipulation of cleared elements in RepeatedPtrField.
212208
// Owner: mkruskal@
213209
#define PROTOBUF_FUTURE_REMOVE_CLEARED_API 1

src/google/protobuf/port_undef.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@
117117

118118
#ifdef PROTOBUF_FUTURE_BREAKING_CHANGES
119119
#undef PROTOBUF_FUTURE_BREAKING_CHANGES
120-
#undef PROTOBUF_FUTURE_MAP_PAIR_UPGRADE
121120
#undef PROTOBUF_FUTURE_REMOVE_CLEARED_API
122121
#endif
123122

0 commit comments

Comments
 (0)