Commit Graph

2618 Commits

Author SHA1 Message Date
Vladislav Shchapov
6392dba21c Fix warning: identifier '_a' preceded by whitespace in a literal operator declaration is deprecated (#3748)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-12-09 08:16:57 -08:00
Albert Santoni
9c3c107c8c Fix compile with GCC 6.3.0 (bug #3738) (#3743) 2023-12-08 09:36:33 -08:00
js324
573d74395b error on bool arg w/ char pres_type (#3734) 2023-12-05 13:45:10 -08:00
Ivan Shapovalov
71bd51e6c2 Implement %j specifier for std::chrono::duration (#3732)
This adds support for `%j` presentation type for duration types:

> "If the type being formatted is a specialization of duration, the decimal
number of days without padding."

Fixes #3643.
2023-12-03 07:29:58 -08:00
Félix-Antoine Constantin
99b9fbf8ef Add formatter for std::source_location (#3730) 2023-11-30 10:05:56 -08:00
Victor Zverovich
8f83ee2ad1 Apply coding conventions 2023-11-30 08:24:02 -08:00
Victor Zverovich
2a8a694466 Clarify that mixing code unit types is deprecated 2023-11-30 08:20:01 -08:00
Victor Zverovich
04718008ab Minor cleanup 2023-11-30 07:43:31 -08:00
js324
b87ea22e29 Add native and generic representation for filesystem::path format spec (#3729) 2023-11-29 14:49:36 -08:00
Victor Zverovich
6988be3878 Bump version 2023-11-25 09:11:53 -08:00
Victor Zverovich
2d1e4bb35e Remove a useless comment 2023-11-25 09:05:20 -08:00
Corentin Schreiber
7f8d419115 Fix overflow in time_point formatting with large dates (#3727)
* Fix #3725 and rename fmt_safe_duration_cast to fmt_duration_cast
The function is now more generic and will handle all casts. It also
takes care of toggling safe vs unsafe casts using
FMT_SAFE_DURATION_CAST.

* Refactor fmt_duration_cast to put #ifdef inside the function

* Fix compilation error with FMT_USE_LOCAL_TIME
2023-11-25 08:36:55 -08:00
Victor Zverovich
06f1c0d725 Clarify that calling non-const format is deprecated 2023-11-24 10:21:57 -08:00
Victor Zverovich
8a39388516 Fix the default locale in ostream_formatter 2023-11-24 09:24:43 -08:00
Peter Johnson
dd6f657a79 Remove this-> from decltype (#3723)
* Remove this-> from decltype

The latest version of MSVC doesn't like it, and removing it doesn't seem to harm anything.

* Add ifdef for GCC < 5
2023-11-22 09:46:04 -08:00
Victor Zverovich
c13753a70c Fix handling of invalid Unicode in precision 2023-11-18 08:36:11 -10:00
Ole Bøe
864a8b5f38 fix: support optional<T> with format_as(T) (#3713)
Formatting a std::optional<T> where T had a custom format_as(T) function failed to compile with clang,
due to set_debug_format being hidden by private inheritance. This fix makes the function available through a using clause.
2023-11-16 15:02:33 -08:00
Victor Zverovich
649fe0fc8b Fix handling of null strings with the s specifier 2023-11-15 17:03:01 -10:00
Kai Aoki
45e124ee43 Added workaround for old xcode compiler bug (#3716)
* Added macros to disable std::filesystem and std::variant as a workaround for old xcode bugs

* Change macro to positive logic
2023-11-15 09:19:08 -08:00
Victor Zverovich
6b0082e6c7 Improve OpenBSD workaround 2023-11-07 09:24:33 -10:00
Victor Zverovich
4548d1eae2 Make write_escaped_path more portable 2023-11-07 05:46:15 -10:00
Victor Zverovich
050d41e857 Make get_path_string more portable 2023-11-06 14:34:53 -10:00
hotwatermorning
b35d4e40fe fix: use FMT_HAS_INCLUDE instead of __has_include 2023-11-03 15:10:40 -07:00
hotwatermorning
acaf83f40f feat: enable building with gcc 4.8 2023-11-03 02:38:05 +09:00
hotwatermorning
05aa783779 feat: include xlocale.h only if exists 2023-11-03 02:38:05 +09:00
Carl Smedstad
e0d3e346d2 Wrap Char in array to avoid pointer arithmetic (#3695)
This resolves the following finding reported by Coverity Static Analysis
v2023.6.1 on line 1964 of fmt/include/fmt/format.h:

  ptr_arith: Using &v as an array. This might corrupt or misinterpret
             adjacent memory locations.
2023-10-31 14:05:46 -07:00
Victor Zverovich
19276d7325 Fix an inconsistentcy between to_string and format 2023-10-28 08:05:11 -07:00
Dimitrij Mijoski
2a2c6e676f Fix flushing C++ iostreams before calling write_console() (#3689)
This change correctly implements https://wg21.link/P2539/ for both
C streams and C++ iostreams.

Fixes #3688.
2023-10-25 13:13:31 -07:00
Roman Koshelev
3b7f58a8b3 add buffer flush before direct write 2023-10-24 16:02:37 -07:00
Victor Zverovich
d9063baf22 Fix perf regression in ostream::print 2023-10-15 08:23:36 -07:00
Victor Zverovich
f7542c5761 Apply clang-format 2023-10-14 06:52:43 -07:00
Richard Kellnberger
bb8d50f04b add a suffix for days and fix the one for minutes (#3664) 2023-10-07 12:45:34 -07:00
Giel van Schijndel
f76603f21e fix: make std::bitset formattable again (#3660)
* fix: make std::bitset formattable again

It used to be formattable via operator<<(ostream&) implicitly. Make it
formattable again, but this time via formatter specialization.

* fix: make nested_formatter constexpr default constructible
2023-10-03 09:53:47 -07:00
Victor Zverovich
72e883e163 Diagnose unsupported code unit types 2023-10-01 08:37:21 -07:00
Victor Zverovich
2dd4fa8742 Remove an ostream hack incompatible with libc++ 17 2023-09-26 12:42:37 -07:00
Victor Zverovich
06b20387ae Optimize fractional_part_rounding_thresholds 2023-09-22 13:26:57 -07:00
Victor Zverovich
649f2460db Apply clang-format 2023-09-22 09:07:43 -07:00
Greg Sjaardema
7529af8f99 Workaround intel bug (#3652)
* Workaround intel bug

Potential workaround / restructure for the intel bug that is the cause of #3645.

Make the variable in the external struct instead an embedded static constexpr variable in the only function that uses the variable.

* Finish the proposed change -- remove struct accessor

* Refactor proposed intel fix.

Moved variable out of function to avoid specialization on Float.  Made it a separate function that is called from format_float.

* Fix incorrect function name.

* Add missing inline.
2023-09-20 18:57:55 -07:00
Giel van Schijndel
a3a74fa7f3 fix: mark fmt::streamed() as constexpr (#3650)
Because it's just performing a very basic type conversion that can be
done at constexpr time.

My use case simultaneously creates a
`fmt::basic_format_string<some_type_conversion<Args...>>` instance and
performs `some_type_conversion<Args>(args)...`. `some_type_conversion`
optionally applies `fmt::streamed(arg)` to a subset of types. This needs
to be `constexpr` because `basic_format_string`'s constructor is
`consteval`.
2023-09-19 08:42:34 -07:00
Sascha Scandella
8ef4db4b96 Use datatype of underlying data (#3647) 2023-09-19 07:31:36 -07:00
Victor Zverovich
0e01e46c11 Implement nested formatter 2023-09-18 14:21:21 -07:00
Dana Jansens
f6ca4ea199 Avoid a space in the UDL definition (#3610)
* Avoid a space in the UDL definition except on GCC before 4.9

Clang 18 has grown a warning about the space being deprecated which
is enabled by default in their nightly binaries. However GCC before 4.9
will reject the UDL definition unless there is a space there, so we need
to keep the space conditionally for it.

* Remove UDLs on GCC before 4.9 to simplify things

GCC before 4.9 rejects the syntax that is now
rejected on more modern compilers.

* Disable compile-error-test on GCC < 4.9

This avoids the UDL tests failing as GCC < 4.9 can not parse UDLs
without a space, but the space is malformed in modern compilers.
2023-09-18 08:09:42 -07:00
Gleb Mazovetskiy
a8a73da7e4 Add an option to avoid wchar APIs on Windows (#3636)
With this, fmt can be used on Windows 98 and the Original Xbox with:

    set(FMT_OS OFF)

It is not exposed as a CMake option but one can define it manually
in the fmt subproject, e.g.:

    target_compile_definitions(fmt PUBLIC FMT_WINDOWS_NO_WCHAR)

Fixes #3631
2023-09-17 08:49:51 -07:00
Victor Zverovich
bfdf50d183 Minor cleanup 2023-09-16 08:16:59 -07:00
Chloe
571a9b7b26 Replace usage of C++17 library feature with C++11 (#3638) 2023-09-16 08:07:03 -07:00
Victor Zverovich
6c088be8ec Cleanup handling of visibility 2023-09-16 07:40:08 -07:00
Vladislav Shchapov
016b1faede Fix symbol leak (#3627)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-09-16 07:26:36 -07:00
Victor Zverovich
d4987546a4 Add an experimental nested formatter 2023-09-10 11:56:55 -07:00
Victor Zverovich
5bdce181f1 Mark styled_arg as a view to prevent lifetime issues 2023-09-09 08:16:45 -07:00
cyy
a4b7b24b7b fix redundant redeclaration of ‘constexpr’ static data member (#3630) 2023-09-08 16:20:32 -07:00