fmtlib / fmt

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

use `fmt::format_to` with `vector<char>` and `FMT_COMPILE` #4206

Closed trim21 closed 1 month ago

trim21 commented 1 month ago

I'm new to c++, apology if this is not a good issue.

I'm coming from https://github.com/fmtlib/fmt/issues/1771 , but I'm using a vector<char> as memory buffer.

And fmt::format_to(std::back_inserter(out), FMT_COMPILE("{}"), val) works if out is std::string of fmt::memory_buffer but not std::vector<char>, and fmt::format_to(std::back_inserter(buffer), "{}", val) works for vector<char>

Is it possible to add support for vector<char> and FMT_COMPILE?

https://godbolt.org/z/h6xoG65he

vitaut commented 1 month ago

Thanks for reporting. We should detect presence of append with SFINAE in https://github.com/fmtlib/fmt/blob/2b6a786e3507a9a5a856cb58c09413acf212c7ed/include/fmt/base.h#L1974-L1981

vitaut commented 1 month ago

Done in #4211.

trim21 commented 1 month ago

thanks