-
Notifications
You must be signed in to change notification settings - Fork 566
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
Build against more recent versions of {fmt} #2639
Conversation
template <> | ||
struct formatter<OIIO::TypeDesc> { | ||
// Parses format specification | ||
// C++14: constexpr auto parse(format_parse_context& ctx) { |
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.
Did you mean to add contexpr
here in c++14 mode ?
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.
No, I just meant for the comment to remind myself that when C++14 is our minimum, I can switch to the more compact declaration. I barely noticed the constexpr part, the big difference was that C++11 needs the "-> decltype(...)" to go along with the "auto", but C++14 can deduce the return type.
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.
I'm assuming that constexpr
is desirable for when you want to use the compile time format string parsing feature - but I guess we are not using this widely right now?
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.
Not using it at all for the moment.
fmt is supposed to (if you include fmt/ostream.h) automatically support any user type that defines an `operator<<()`. And so it did through version 6.1.2. Starting with 6.2.x, the presence of `operator bool()` throws it off, particularly for our TypeDesc, which started rendering as "true" rather than "uint8" or whatever. It seems that the fact that it can convert to bool takes precedence, it formats as a bool, rather than notice that there's a stream ouput option. In this patch, we add a custom formatter for TypeDesc, which solves the problem for `format("{}", typedesc)`, but unfortunately not for `sprintf("%s", typedesc)`. I've filed an issue, but in any case, the workaround to avoid incorrect formatting when using sprintf is to be sure to use typedesc.c_str(). Signed-off-by: Larry Gritz <lg@larrygritz.com>
…n#2639) fmt is supposed to (if you include fmt/ostream.h) automatically support any user type that defines an `operator<<()`. And so it did through version 6.1.2. Starting with 6.2.x, the presence of `operator bool()` throws it off, particularly for our TypeDesc, which started rendering as "true" rather than "uint8" or whatever. It seems that the fact that it can convert to bool takes precedence, it formats as a bool, rather than notice that there's a stream ouput option. In this patch, we add a custom formatter for TypeDesc, which solves the problem for `format("{}", typedesc)`, but unfortunately not for `sprintf("%s", typedesc)`. I've filed an issue, but in any case, the workaround to avoid incorrect formatting when using sprintf is to be sure to use typedesc.c_str(). Signed-off-by: Larry Gritz <lg@larrygritz.com>
…n#2639) fmt is supposed to (if you include fmt/ostream.h) automatically support any user type that defines an `operator<<()`. And so it did through version 6.1.2. Starting with 6.2.x, the presence of `operator bool()` throws it off, particularly for our TypeDesc, which started rendering as "true" rather than "uint8" or whatever. It seems that the fact that it can convert to bool takes precedence, it formats as a bool, rather than notice that there's a stream ouput option. In this patch, we add a custom formatter for TypeDesc, which solves the problem for `format("{}", typedesc)`, but unfortunately not for `sprintf("%s", typedesc)`. I've filed an issue, but in any case, the workaround to avoid incorrect formatting when using sprintf is to be sure to use typedesc.c_str(). Signed-off-by: Larry Gritz <lg@larrygritz.com>
fmt is supposed to (if you include fmt/ostream.h) automatically
support any user type that defines an
operator<<()
. And so it didthrough version 6.1.2.
Starting with 6.2.x, the presence of
operator bool()
throws it off,particularly for our TypeDesc, which started rendering as "true" rather
than "uint8" or whatever. It seems that the fact that it can convert
to bool takes precedence, it formats as a bool, rather than notice that
there's a stream ouput option.
In this patch, we add a custom formatter for TypeDesc, which solves
the problem for
format("{}", typedesc)
, but unfortunately not forsprintf("%s", typedesc)
. I've filed an issue, but in any case, theworkaround to avoid incorrect formatting when using sprintf is to be
sure to use typedesc.c_str().
Signed-off-by: Larry Gritz lg@larrygritz.com