BLI: support multiple arguments for value in *_as methods of Map

This allows us to build more complex values in-place in the map.
Before those values had to be build separately and then moved into the map.

Existing calls to the Map API remain unchanged.
This commit is contained in:
2021-04-17 18:39:35 +02:00
parent 5cf6f570c6
commit d0d85742fc
3 changed files with 56 additions and 45 deletions

View File

@@ -604,6 +604,15 @@ TEST(map, GenericAlgorithms)
EXPECT_EQ(std::count(map.keys().begin(), map.keys().end(), 7), 1);
}
TEST(map, AddAsVariadic)
{
Map<int, StringRef> map;
map.add_as(3, "hello", 2);
map.add_as(2, "test", 1);
EXPECT_EQ(map.lookup(3), "he");
EXPECT_EQ(map.lookup(2), "t");
}
/**
* Set this to 1 to activate the benchmark. It is disabled by default, because it prints a lot.
*/