Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.
This repository was archived by the owner on May 8, 2025. It is now read-only.

Add advanced printf-style formatting options to w::format. #3

Description

@simonask

Currently w::format only does plain interpolation. It would be great if it could support syntax like this:

w::format("{0:.2}", 123); // => "0.00"

The format options should be per-interpolation, so the same argument can be interpolated multiple times with different format arguments:

w::format("{0:09.2} <=> {0:+x}", 10); // => "000000010.00 <=> +0xa"

For numbers (both integers and floats), all the options of POSIX printf should be supported. If a float-options is given to with an integer argument, or vice versa, the input value should be static_cast'ed to the appropriate type before interpolation.

Hexadecimal presentation formats should reinterpret_cast the input to a matching integer representation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions