Hadriel Kaplan wrote:
``` struct Encoding { char alphabetLetter; int ocurrences; };
Encoding e {'a', 112}; ``` I really expect that to be output as "a 112”.
You shouldn’t want it to, imo. One of the big benefits of using PFR is you can stream structs out for debugging/logging. It’s completely useless to stream a char as a char for debugging, because the whole point is you don’t know what’s in the char, which is why you’re debugging it.
The default behavior of << for chars and strings is a bit useless not just for debugging and logging, but for pretty much any use. E.g. if you have struct X { std::string a; std::string b; }; X{ "foo bar", "" }, X{ "foo", "bar" } and X{ "", "foo bar" } will all output "foo bar" under Andzrej's preferred behavior. It's hard to think where this could be useful. For logging and debugging, we want (plain, not signed or unsigned) chars to come out as 'a' or '\x04', and for strings to come out as "str\x00ing". On whether PFR needs to do this or not, I have no opinion, but it's indeed what's needed for many use cases. (I see std::quoted in the code, so this would probably match the intent.)