Skip to content

Support for ranges #181

@gnzlbg

Description

@gnzlbg

Add support for printing ranges. Ideally:

std::initializer_list<int> a = {0, 2, 3, 4};
print("range: \"{r{}, }\"\n", a);
print("range: \"{r{}| }\"\n", a);
std::initializer_list<std::initializer_list<int>> a = { {0, 1}, {2, 3}, {4}};
print("range: \"{r{r{}, }| }\"\n", a);

would print

range "0, 2, 3, 4"
range "0 | 2 | 3 | 4"
range "0, 1 | 2, 3 | 4"

This would require a new format specifier, e.g. r, followed by a format specifier for the range element and a separator string: r{}sep. Note that r{r{}sep0}sep1 allows dealing with ranges of ranges.
A definition of Range, e.g., anything that can be called with non-member begin and end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions