Viatorus / emio

A safe and fast high-level and low-level character input/output library for bare-metal and RTOS based embedded systems with a very small binary footprint.
https://viatorus.github.io/emio/
MIT License
128 stars 3 forks source link

`writer::write_float` method missing? #95

Open IndianBoy42 opened 1 week ago

IndianBoy42 commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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 commented 1 week ago

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.