Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
std::vector に 1890 個の要素があり、最初の 1000 個を保持して残りを消去し、次の 890 個の要素を保持して最初の 1000 個を消去したい場合、ループが必要なようです。 これを行うためのより便利な方法はありますか?
std::vectorにはerase、明示的なループを使用せずに要素の範囲を消去できるメンバー関数があります。例えば:
std::vector
erase
std::vector<whatever> x(1890); // erase first 1000 items x.erase(x.begin(), x.begin()+1000);