私が持っているとしましょうstd::vector<std::pair<int,Direction>>
。
ベクトルからペアを削除するために、erase-remove_if イディオムを使用しようとしています。
stopPoints.erase(std::remove_if(stopPoints.begin(),
stopPoints.end(),
[&](const stopPointPair stopPoint)-> bool { return stopPoint.first == 4; }));
.first 値が 4 に設定されているすべてのペアを削除したいと考えています。
私の例では、ペアがあります:
- 4, Up
- 4, Down
- 2, Up
- 6, Up
ただし、erase-remove_if を実行すると、次のものが残ります。
- 2, Up
- 6, Up
- 6, Up
ここで何が間違っていますか?