fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
19.9k stars 2.43k forks source link

Support for a single `char` separator in `fmt::join()` #3936

Closed jimmy-park closed 3 months ago

jimmy-park commented 3 months ago

I thought I could do this at the first place, but I failed.

fmt::format("{}", fmt::join(vec, '\n'));

It turns out fmt::join() only supports fmt::string_view-convertible separators. So I just replace '\n' to "\n", and it works fine.

It would be nice to have this kind of APIs when handling a single character. @vitaut Would you accept adding more APIs just to support char parameters?

vitaut commented 3 months ago

Thanks for the suggestion but you can already pass a single code unit (character):

fmt::format("{}", fmt::join(vec, "\n"));

so there is no reason to add another API for this especially considering that strings are multi-byte.