Commit Graph
1520 Commits
Author SHA1 Message Date
Alex Dewar 8a8f4825a3 Fix: isnan() shouldn't cause FP exceptions
Fixes #3948.
2024-05-02 09:36:21 -07:00
Diego Ramírez cf1f55f798 Specialize formatter for all std::basic_string types (#3943)
* Specialize `formatter` for all `std::basic_string` types

* mock-allocator: add member types to make GCC 4.8 happy
2024-04-23 08:44:41 -07:00
Matthias Moulin 116a9ce488 Added FMT_IMPORT_STD feature macro (#3928) 2024-04-10 11:48:32 -07:00
ShifftC 5eb68c0ef2 Fix mix-up of 'FMT_BEGIN_EXPORT' and 'namespace detail'. (#3924) 2024-04-08 09:46:20 -07:00
Philippe Proulx 4e8640ed90 Fix: enable FMT_NORETURN without exception support too (#3917)
When building `format.cc` as such with GCC 13.2.1:

    $ g++ -c format.cc -DFMT_EXCEPTIONS=0 -Wmissing-noreturn -Werror

I get:

    In file included from format.cc:8:
    fmt/format-inl.h: In function ‘void fmt::v10::detail::assert_fail(const char*, int, const char*)’:
    fmt/format-inl.h:30:15: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
       30 | FMT_FUNC void assert_fail(const char* file, int line, const char* message) {
          |               ^~~~~~~~~~~
    fmt/format-inl.h: In function ‘void fmt::v10::report_error(const char*)’:
    fmt/format-inl.h:129:15: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
      129 | FMT_FUNC void report_error(const char* message) {
          |               ^~~~~~~~~~~~
    cc1plus: all warnings being treated as errors

Note that, with `FMT_EXCEPTIONS` defined to 0:

‣ report_error(const char *) uses FMT_THROW() which expands to calling
  assert_fail().

‣ assert_fail() calls std::terminate() which has the `[[noreturn]]`
  attribute since C++11 [1].

Therefore, with `FMT_EXCEPTIONS` defined to 0, both assert_fail() and
report_error() need to have the `[[noreturn]]` attribute too (if
available). In other words, `FMT_NORETURN` doesn't depend on
`FMT_EXCEPTIONS`.

Also adding `FMT_NORETURN` to two on_error() functions which call
report_error(const char *).

Other report_error() overloads eventually return, therefore they don't
need `FMT_NORETURN`.

[1]: https://en.cppreference.com/w/cpp/error/terminate

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
2024-04-04 17:15:18 -07:00
Victor Zverovich 5d63e87d23 Add a formatter for float128 2024-03-22 15:41:50 +09:00
Victor Zverovich aecec01b34 Initial support for extended FP types 2024-03-22 15:08:25 +09:00
Victor Zverovich 5af88653eb Cleanup 2024-03-22 13:46:03 +09:00
Vladislav Shchapov 6c7cc6a06f Fix group_digits for negative integers (#3901)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-03-19 13:03:57 -07:00
Vladislav Shchapov 9f3fc6e38b Add XChar support into nested_formatter
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-03-17 15:26:18 -07:00
Baardi ae1e93d34d Fix warning C4702 emitted from format.h (MSVC) (#3866) 2024-02-28 07:47:13 -08:00
Bruce Mitchener 0879504796 Fix typo in typename. containter_type -> container_type. (#3844) 2024-02-08 06:24:55 -08:00
Victor Zverovich 06311ed1ce Fix fixed rounding around zero in Dragon 2024-02-03 10:13:58 -08:00
Frank Richter 71a4a8d479 Really fix MSVC warning about <bit> only being available in C++20. (#3832)
* Really fix MSVC warning about <bit> only being available in C++20.

The warning states "The contents of <bit> are available only with C++20 or later.",
but the check was for C++17 and later.

* Change <bit> inclusion check per https://github.com/fmtlib/fmt/pull/3832#discussion_r1471144867
2024-01-30 10:42:35 -08:00
Victor Zverovich 4c5b4af04d Improve name argument validation 2024-01-19 16:13:43 -08:00
Victor Zverovich b2cde48de5 Reduce usage of float_specs 2024-01-17 08:27:03 -08:00
Victor Zverovich 8510838db1 Make format_specs not depend on code unit type 2024-01-17 07:50:52 -08:00
Victor Zverovich 090ee13595 Pass char type to write 2024-01-17 06:07:29 -08:00
Victor Zverovich e954823531 Make fill independent on code unit type 2024-01-15 15:00:28 -08:00
Victor Zverovich fe0d910a7d Replace multiple error reporting mechanisms with report_error 2024-01-15 07:23:06 -08:00
Victor Zverovich f9294f0e60 Improve handling of format specs 2024-01-15 06:31:24 -08:00
Victor Zverovich c98a5a599f Remove unnecessary checks 2024-01-14 17:41:49 -08:00
Victor Zverovich d70729215f Fix constness 2024-01-14 06:44:38 -08:00
Victor Zverovich cacdf1439f Remove nonstandard alias 2024-01-13 15:56:16 -08:00
Victor Zverovich d0963d4823 Make ranges only depend on fmt/base.h 2024-01-13 09:54:19 -08:00
Victor Zverovich da0f84c42c Cleanup copy functions and move to base.h 2024-01-13 09:31:20 -08:00
Vladislav Shchapov 21b0458291 Use std::allocator_traits (#3804)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-01-13 08:48:37 -08:00
Vladislav Shchapov df6a3564b0 Fix MSVC warning: "The contents of <bit> are available only with C++20 or later." (#3807)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-01-13 08:26:44 -08:00
Victor Zverovich 297b22f585 Remove <memory> dependency 2024-01-12 09:09:19 -08:00
Victor Zverovich 3c9608416a Remove redundant detection of experimental string_view 2024-01-12 07:45:07 -08:00
Victor Zverovich 0cdee904a4 Add a missing num_bits specialization 2024-01-12 07:20:12 -08:00
Victor Zverovich fd87a23d34 Reduce memory dependency 2024-01-10 20:00:15 -08:00
Victor Zverovich b71ef65b6e Remove iterator dependency 2024-01-10 18:52:53 -08:00
Victor Zverovich c5340539f9 Remove unnecessary trait specialization 2024-01-10 18:11:37 -08:00
Victor Zverovich da7a232b9e Cleanup contexts 2024-01-10 13:09:55 -08:00
Vladislav Shchapov 6f5d53ce08 Add fmt::is_contiguous<std::basic_string<Char, Traits, Allocator>>
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-01-10 10:47:39 -08:00
Vladislav Shchapov 961df829b9 Fix buffer overflow if output iterator is std::back_insert_iterator and value is escaped (debug format)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-01-10 09:15:16 -08:00
Victor Zverovich 401f087394 Fix write_uintptr_fallback 2024-01-10 09:09:57 -08:00
Victor Zverovich 4331abed26 Move fmt::format to fmt/format.h 2024-01-10 06:43:12 -08:00
Victor Zverovich 79f1506fe3 Add base.h 2024-01-09 19:36:12 -08:00
Victor Zverovich 6af30d8f75 Remove legacy workaround 2024-01-08 20:13:50 -08:00
Victor Zverovich a5ae9ae19d Split standard context into a separate class and optimize 2024-01-08 07:08:49 -08:00
Victor Zverovich 23e8109d8d Remove buffer_appender 2024-01-07 22:03:02 -08:00
Victor Zverovich 679af1f5cc Remove redundant get_container 2024-01-07 19:31:26 -08:00
Victor Zverovich 48d7fb265b Merge back_insert_iterator and appender 2024-01-07 18:43:27 -08:00
Victor Zverovich dbdfc99fa1 Don't crash if flush fails during unwinding 2024-01-07 14:55:16 -08:00
Victor Zverovich c1d9e88402 Remove unnecessary final and apply clang-format 2024-01-07 13:08:17 -08:00
Victor Zverovich ae9b0b521b Disable transitive includes 2024-01-06 15:22:13 -08:00
Victor Zverovich 0641b844ac Cleanup string traits 2024-01-05 19:31:04 -08:00
Victor Zverovich e0b604beb1 Remove a redundant function 2024-01-04 15:59:33 -08:00