Closed
Description
While #613 would be great, but will probably only supported for c++17.
Another approach would be to have kind of prepared templates (or prepared statements - a bit like in db, but fmt need not to store or manage the handle anywhere - the handle itself would contain all the needed info).
The user would pass a format string he expects to use a lot and get a handle to a "compiled" version of the format string:
// fmt returns a handle object that can be executed like this:
auto handle = fmt::prepare("My name is {}. I am {} years old.");
// and then the user can make heavy use of it
auto result = handle->format(arg1, arg2);
// or maybe
auto result = fmt::format(handle, arg1, arg2);
The handle would contain an efficient representation of the format - list of actual formatters to use, their flags, and their offsets in the format string.
I am not sure if the result would be much faster for simple format strings, but complex format strings, it might give big performance boost.
Metadata
Metadata
Assignees
Labels
No labels