[upstream_utils] StringMap: fix structured bindings with move-only types (#7127)

This commit is contained in:
Ryan Blue
2024-09-25 01:11:41 -04:00
committed by GitHub
parent 69af7785f6
commit b8ff3fcee2
40 changed files with 112 additions and 38 deletions

View File

@@ -525,6 +525,16 @@ TEST_F(StringMapTest, StructuredBindings) {
}
}
TEST_F(StringMapTest, StructuredBindingsMoveOnly) {
StringMap<MoveOnly> A;
A.insert(std::make_pair("a", MoveOnly(42)));
for (auto &&[Key, Value] : A) {
EXPECT_EQ("a", Key);
EXPECT_EQ(42, Value.i);
}
}
namespace {
// Simple class that counts how many moves and copy happens when growing a map
struct CountCtorCopyAndMove {