GF2::Vector — Replace Bit-Vector’s Contents

Replaces some of this bit-vector’s values with those of another.

constexpr Vector &replace(std::size_t i0, const Vector &with);  (1)
constexpr Vector &replace(const Vector &with);                  (2)
1 Starting at element i0 replace the bit-vector values with those from the bit-vector with.
2 Starting at element 0 replace the bit-vector values with those from the bit-vector with.
The sub-vector with we are copying from must fit inside the existing bit-vector! If the GF2_DEBUG flag is set at compile time this is checked and any violation will cause the program to abort with a helpful message.

Both methods return a reference to *this so can be chained with other calls.

Example
#include <GF2/GF2.h>
int main()
{
    GF2::Vector<> v("1111111111"), u("000");
    std::cout << "v: " << v << '\n';
    v.replace(7,u);                     (1)
    std::cout << "v: " << v << '\n';
    v.replace(u);                       (2)
    std::cout << "v: " << v << '\n';
}
1 Replaces the final three elements of v with those from u.
2 Replaces the first three elements of v with those from u.
Output
v: 1111111111
v: 1111111000
v: 0001111000
See Also

sub