I have a map with 16 million entries and calling clear() takes around 50 to 100 milliseconds.
The clear() function destroys every entry in a for loop. But if both the key and value types are 'is_trivially_destructible', (for example map<int, int>) then it does not have to call the destructor on every key/value.
This reduces the time spent in clear() to less than 1 microsecond.
I have a map with 16 million entries and calling clear() takes around 50 to 100 milliseconds.
The clear() function destroys every entry in a for loop. But if both the key and value types are 'is_trivially_destructible', (for example map<int, int>) then it does not have to call the destructor on every key/value.
This reduces the time spent in clear() to less than 1 microsecond.