bit::vector — Clear

Clears out the contents of a bit-vector:

constexpr bit::vector &clear();

The bit-vector’s size() becomes 0, but its capacity is not changed. This method returns a reference to *this so it can be chained with other calls.

Example

#include <bit/bit.h>
int main()
{
    auto v = bit::vector<>::ones(8);
    std::cout << "v: " << v << '\n';
    v.clear();
    std::cout << "v: " << v << '\n';
}

Output

v: [1 1 1 1 1 1 1 1]
v: []

See Also

vector::pop

Back to top