InversionList.toString

Obtain a textual representation of this InversionList in form of open-right intervals.

The formatting flag is applied individually to each value, for example:

  • %s and %d format the intervals as a [low .. high) range of integrals
  • %x formats the intervals as a [low .. high) range of lowercase hex characters
  • %X formats the intervals as a [low .. high) range of uppercase hex characters
  • struct InversionList(SP = GcPolicy)
    void
    toString
    (
    Writer
    )
    (
    scope Writer sink
    ,
    scope const ref FormatSpec!char fmt
    )

    Examples

    import std.conv : to;
    import std.format : format;
    import std.uni : unicode;
    
    // This was originally using Cyrillic script.
    // Unfortunately this is a pretty active range for changes,
    // and hence broke in an update.
    // Therefore the range Basic latin was used instead as it
    // unlikely to ever change.
    
    assert(unicode.InBasic_latin.to!string == "[0..128)");
    
    // The specs '%s' and '%d' are equivalent to the to!string call above.
    assert(format("%d", unicode.InBasic_latin) == unicode.InBasic_latin.to!string);
    
    assert(format("%#x", unicode.InBasic_latin) == "[0..0x80)");
    assert(format("%#X", unicode.InBasic_latin) == "[0..0X80)");
    

    Meta