a map confuseness

1
2
3
4
5
6
7
8
9
10
#include <map>
#include <iostream>
#include <algorithm>
int main()
{
	std::map<int, int> iim = { {1,2},{1,3},{2,2},{3,2}};
	//erase all elements whose values is 2
	iim.erase(std::remove_if(iim.begin(), iim.end(), [](const std::pair<const int, int>& data) {return data.second == 2;}), iim.end());
	std::cin.get();
}

//compilation error on Visual Studio 2015
The erase-remove idiom cannot be used for associative containers.

http://stackoverflow.com/questions/800955/remove-if-equivalent-for-stdmap
Topic archived. No new replies allowed.