Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Latest commit

 

History

History
21 lines (16 loc) · 608 Bytes

remove.md

File metadata and controls

21 lines (16 loc) · 608 Bytes

remove

Description : Removes elementes from range [first, last) that matches a value and returns a new past-the-end iterator for the new end of range.

Example:

    std::vector<int> v {3, 5, 3, 1, 2, 3};

    // removes all elements that are 3
    auto newEndIt = std::remove(v.begin(), v.end(), 3);
    
    // Erase elements from [newEndIt, v.end()]
    v.erase(newEndIt, v.end());

    // v is now {5, 1, 2}
    for (auto value : v) { 
        std::cout << value << " "; 
    }

See Sample code Run Code