Skip to content
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

writer::write_float method missing? #95

Open
IndianBoy42 opened this issue Jun 16, 2024 · 3 comments
Open

writer::write_float method missing? #95

IndianBoy42 opened this issue Jun 16, 2024 · 3 comments

Comments

@IndianBoy42
Copy link

I would think anything formattable by format/format_to should also be able to be directly formatted and written to a emio::writer. Also would it be better/possible to just have an overloaded writer::write method instead of write_char,write_str,write_int,...

@Viatorus
Copy link
Owner

Yes, this function is missing (PRs are welcome).

write vs. write_...: I understand what you mean but each function has different optional parameters. I am not a big fan of unclear overload resolutions. Maybe as additional function.

@IndianBoy42
Copy link
Author

Maybe we can have an additional function that just forwards to format_to(writer, "{}", value) as a more generic convenience method and then have write_* as more configurable (and maybe slightly more optimized) methods for specific values.

I will have to look into how the formatting machinery actually works but I can try and get a PR in next weekend

@Viatorus
Copy link
Owner

The API of write_float API should be similar to std::to_chars.

The generic template<T> write(T) could dispatch to write_int/char/str/float depending on T. Using format_to cannot (easily) work since this would be a circular dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants