Skip to content

Explicit newline character in format string (semantics) #143

Description

@oysstu

The manual clearly states the format string grammar considers all Unicode Pattern_White_Space codes to not be taken into account. However, as a user, I would expect the following parse to fail since the newline character is explicitly added to the format string. The snippet below succeeds, although to a user it looks like it should fail.

auto result = scn::scan<int, double>("42, 3.14, test", "{}, {}\n");

A workaround is adding a string output and changing the format to "{}, {}{:[c^\n]}". This succeeds if there is a trailing newline, but fails in all other cases.

I understand that there's a tradeoff here between grammar strictness and convenience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions