vectorにランダムで作った数値などを格納して利用したい場合に、同じ数字は利用したくないという場合がある。そのようなときに重複した要素を削除する方法。
std::sortでソートして、std::uniqueで重複要素を削除し、eraseでサイズを調整する。
std::vector<int> test; std::sort(test.begin(), test.end()); test.erase(std::unique(test.begin(), test.end()), test.end());