-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: prepared statements #618
Comments
Thanks for the suggestion. It sounds very similar to what Bengt Gustafsson's proposed in https://groups.google.com/a/isocpp.org/forum/#!msg/std-proposals/4wOU-1_3D0A/xiNQSmO1CAAJ:
and, in fact, I've already done most of the work to make this possible, namely separated parsing and formatting as part of compile-time format string parsing support. It still needs to be packaged in an API similar to the one you proposed with the main difference that auto formatter = fmt::prepare<std::string, int>("My name is {}. I am {} years old."); |
BTW #613 can work with C++14. |
Do you think adding this feature, or will you do #613 first ? |
Not sure, #613 will give much better runtime performance but, as you noticed, it will require a modern compiler. This one is a small optimization, mostly for the case when you need to process the same format string multiple times. My main focus right now is addressing standards proposal feedback (#518), but I'll get back to this idea afterwards. |
Hello, does this proposal need to wait for some other dependency than #581, or I can fool around a little and try to implement this? Or you want to postpone it? |
No this doesn't have to wait on anything.
Please do. Contributions are always welcome! |
I think I've finished implementation for this (at least for the first review). Now I'm checking whether my changes are compilable by all of the supported compilers and I have one question. Against which compilers should I check my code? In the |
Testing the ones listed in the Travis CI config should be fine, particularly GCC 4.4 which is the oldest. |
Is |
It has been renamed to |
Is Is there any info regarding possible performance gains to be had with [1] #269 |
Yes, although it has been superseded by |
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:
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.
The text was updated successfully, but these errors were encountered: