我试过这样做:
std::set< pair<int, int> > mySet;
// fill the set with something
mySet.find( make_pair(someValueX, someValueY) )->first = newX;
但是我在编译时遇到以下错误:
error: assignment of member 'std::pair<int, int>::first' in read-only object|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===||
答案 0 :(得分:6)
std::set
的成员是const
,因为更改这些成员可能会使他们的订单无效。您必须擦除该对并在更改后重新插入它。