-
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
Use C++11 compatible std::is_same operations #1519
Conversation
The `operator()` member function of `std::is_same` was added in C++14. For C++11, the `::value` needs to be used instead.
@@ -1038,7 +1038,7 @@ void fallback_format(Double d, buffer<char>& buf, int& exp10) { | |||
// if T is a IEEE754 binary32 or binary64 and snprintf otherwise. | |||
template <typename T> | |||
int format_float(T value, int precision, float_specs specs, buffer<char>& buf) { | |||
static_assert(!std::is_same<T, float>(), ""); |
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.
This is a ctor and not operator()
call and conversion to bool is available in C++11.
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.
Does it fail with brace initialization std::is_same<T, float>{}
too?
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.
Yes, but it isn't a compilation failure, but the static assert triggers:
/scratch/xxxxxxx/xxxxxx-test/fmt/format-inl.h(1082): error: static assertion failed with ""
static_assert(!std::is_same<T, float>{}, "");
^
detected during:
instantiation of "void fmt::v6::internal::basic_writer<Range>::write(T, fmt::v6::internal::basic_writer<Range>::format_specs) [with Range=fmt::v6::buffer_range<char>, T=float, <unnamed>=0]" at line 1955 of "/scratch/yyyyyy/xxxxxx-test/fmt/format.h"
instantiation of "fmt::v6::internal::arg_formatter_base<Range, ErrorHandler>::iterator fmt::v6::internal::arg_formatter_base<Range, ErrorHandler>::operator()(T) [with Range=fmt::v6::buffer_range<char>, ErrorHandler=fmt::v6::internal::error_handler, T=float, <unnamed>=0]" at line 1082 of "/scratch/yyyyyy/xxxxxx-test/fmt/core.h"
instantiation of "auto fmt::v6::visit_format_arg(Visitor &&, const fmt::v6::basic_format_arg<Context> &)->decltype((<expression>)) [with Visitor=fmt::v6::arg_formatter<fmt::v6::buffer_range<char>>, Context=fmt::v6::format_context]" at line 3266 of "/scratch/yyyyyy/xxxxxx-test/fmt/format.h"
instantiation of "void fmt::v6::format_handler<ArgFormatter, Char, Context>::on_replacement_field(const Char *) [with ArgFormatter=fmt::v6::arg_formatter<fmt::v6::buffer_range<char>>, Char=char, Context=fmt::v6::format_context]" at line 2673 of "/scratch/yyyyyy/xxxxxx-test/fmt/format.h"
instantiation of "void fmt::v6::internal::parse_format_string<IS_CONSTEXPR,Char,Handler>(fmt::v6::basic_string_view<Char>, Handler &&) [with IS_CONSTEXPR=false, Char=char, Handler=fmt::v6::format_handler<fmt::v6::arg_formatter<fmt::v6::buffer_range<char>>, char, fmt::v6::format_context> &]" at line 3300 of "/scratch/yyyyyy/xxxxxx-test/fmt/format.h"
instantiation of "Context::iterator fmt::v6::vformat_to<ArgFormatter,Char,Context>(ArgFormatter::range, fmt::v6::basic_string_view<Char>, fmt::v6::basic_format_args<Context>, fmt::v6::internal::locale_ref) [with ArgFormatter=fmt::v6::arg_formatter<fmt::v6::buffer_range<char>>, Char=char, Context=fmt::v6::format_context]" at line 3413 of "/scratch/yyyyyy/xxxxxx-test/fmt/format.h"
instantiation of "fmt::v6::basic_format_context<std::back_insert_iterator<fmt::v6::internal::buffer<Char>>, Char>::iterator fmt::v6::internal::vformat_to(fmt::v6::internal::buffer<Char> &, fmt::v6::basic_string_view<Char>, fmt::v6::basic_format_args<fmt::v6::buffer_context<Char>>) [with Char=char]" at line 1424
compilation aborted for /scratch/yyyyyy/xxxxxx-test/Ioss_FaceGenerator.C (code 2)
Thanks. |
The
operator()
member function ofstd::is_same
was added in C++14. For C++11, the::value
needs to be used instead.I agree that my contributions are licensed under the {fmt} license, and agree to future changes to the licensing.