-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
quotes for string support. #766
Conversation
include/fmt/ranges.h
Outdated
|
||
template<typename Arg> | ||
FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const Arg&, | ||
typename std::enable_if<!is_like_std_string<typename std::decay<Arg>::type>::value>::type* = nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could you wrap long (>80 char length) lines per the style guide (https://google.github.io/styleguide/cppguide.html#Line_Length) here and below?
It would be nice if the quoting worked the same as std::quoted. Also, I'm would really love it if there was something similar to python format's value conversion flag: Notably, an equivalent to the That is: std::string s = "abc \"def\" hij";
fmt::print("s is: {!r}\n", s); Would output:
The reason I'm asking for this, is when formatting error messages. No quote at all:
Vs "dumb quotes" (fmt::format(""{}"", value)):
Vs string representation:
Note: Sorry if this comment is out of scope for this PR. |
That makes sense, but I suggest doing it in a separate PR. |
Would it be a good idea to have an is_char type trait so people have the option to add support for their own chars? |
Adding fmt::is_char and use it instate of function specialization for char ? How about char, wchar_t, char16_t, char32_t ? |
Yeah was thinking something like
Though wouldn't you need to separate wchar_t since it uses a different format? And apparently char16_t and char32_t aren't supported by fmt. I get this error
|
@Remotion, merged, thanks! Could you by any chance submit a section about the new ranges functionality including quotation to the docs? |
std::string and types like it are now printed in double quotes "str".
chars are now printed in single quotes 'A'.