StaticBitArray.toString

Return a string representation of this StaticBitArray.

Two format specifiers are supported:

  • %s which prints the bits as an array, and
  • %b which prints the bits as 8-bit byte packets
  • separated with an underscore.

    struct StaticBitArray(uint capacity, Block = DefaultBlock)
    @safe const @trusted
    void
    toString
    (
    scope void delegate
    (
    scope const(char)[]
    )
    sink
    ,
    FormatSpec!char fmt
    )
    if (
    isUnsigned!DefaultBlock
    )

    Examples

    const b = StaticBitArray!16(([0, 0, 0, 0, 1, 1, 1, 1,
                                  0, 0, 0, 0, 1, 1, 1, 1]));
    const s1 = format("%s", b);
    assert(s1 == "[0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]");
    
    const s2 = format("%b", b);
    assert(s2 == "00001111_00001111");
    

    Meta