etl icon indicating copy to clipboard operation
etl copied to clipboard

Feature request: getting string format in C++ 20 style?

Open jerabaul29 opened this issue 4 years ago • 6 comments

C++ 20 received new ways to format strings, in a python-like way (https://en.cppreference.com/w/cpp/utility/format/format), for example:

std::format("{} {}!", "Hello", "world", "something"); // OK, produces "Hello world!"

This looks amazing, as this is both safe, simple to read and write, and starts to be nearly a "de facto standard" across languages (I finally do not need to get confused when switching back and forth between python and c++, hooray!).

I think that the etl provides something quite similar thanks to the to_string API (https://www.etlcpp.com/to_string.html). However, would it be possible to get something that is fully similar / compliant to the C++ 20 std::format? That would make it even easier to use, would reduce brain overhead switching between etl and "standard" C++ 20.

jerabaul29 avatar Jan 25 '21 09:01 jerabaul29

I'll certainly put it on my ToDo list (which is a bit long at the moment!)

jwellbelove avatar Jan 25 '21 09:01 jwellbelove

That sounds amazing :) No worries no hurries, and many thanks :) .

jerabaul29 avatar Jan 25 '21 09:01 jerabaul29

It's possible to use fmtlib directly with the specific set of definitions for reducing the binary size of the library.

ValentiWorkLearning avatar Oct 23 '21 08:10 ValentiWorkLearning

https://github.com/fmtlib/fmt seems to be great and well tested but use "heavily" the std library.

evantill avatar Oct 17 '22 09:10 evantill

It may be possible to fork the library and modify it (where possible) to use the ETL, and include it in the ETL.

jwellbelove avatar Oct 17 '22 09:10 jwellbelove

I looked at the code and the use of the STL is very extensive. I don't think a modification of the code would be very simple or easy.

jwellbelove avatar Oct 17 '22 11:10 jwellbelove