Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>(), "");
Copy link
Contributor

@vitaut vitaut Jan 15, 2020

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.

Copy link
Contributor

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?

Copy link
Contributor Author

@gsjaardema gsjaardema Jan 15, 2020

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)

static_assert(!std::is_same<T, float>::value, "");
FMT_ASSERT(value >= 0, "value is negative");

const bool fixed = specs.format == float_format::fixed;
Expand Down Expand Up @@ -1113,7 +1113,7 @@ int snprintf_float(T value, int precision, float_specs specs,
buffer<char>& buf) {
// Buffer capacity must be non-zero, otherwise MSVC's vsnprintf_s will fail.
FMT_ASSERT(buf.capacity() > buf.size(), "empty buffer");
static_assert(!std::is_same<T, float>(), "");
static_assert(!std::is_same<T, float>::value, "");

// Subtract 1 to account for the difference in precision since we use %e for
// both general and exponent format.
Expand Down