bit::vector — Descriptive Data

We can output some descriptive data about a bit-vector to a stream. The data is used primarily for debugging purposes.

constexpr void description(std::ostream &s, +
                           const std::string &head = "", +
1                           const std::string &foot = "\n") const;
constexpr void description(const std::string &head = "", +
2                           const std::string &foot = "\n") const;
1
Prints data to an arbitrary stream.
2
Prints the same data to std::cout.

You can send along some arbitrary text that gets prepended or appended to the description of the bit-vector. See the example below.

The format of the output may change from time to time.

Example

#include <bit/bit.h>
int main()
{
1    auto v25 = bit::vector<>::random(32, 0.25);
    v25.description("Random fill with p = 0.25");
}
1
bit::vector of size 32 randomly filled where the probability of getting set elements is 25%.

Output (varies from run to run)

1Random fill with p = 0.25::
bit-vector: 10010000000000000100001001000001
as hex-string:      90002428
number of bits:     32
number of set bits: 6
bit capacity:       64
unused capacity:    32
bits-per-block:     64
blocks used:        1
blocks capacity:    1
1
The optional user-supplied header line.

See Also

vector::to_string

Back to top