Commit Graph

1754 Commits

Author SHA1 Message Date
Alexey Ochapov
684b5b0e40
Fix fallback to runtime API from compile-time API (#2143)
* fix fallback to the runtime API, add FMT_ENABLE_FALLBACK_TO_RUNTIME_API define, add test

* remove `FMT_ENABLE_FALLBACK_TO_RUNTIME_API`

* pass format string to format_to() inside format_to_n() in compile-time API

instead of compiling it inside format_to_n(), to eliminate code duplication
2021-03-04 07:20:57 -08:00
Alexey Ochapov
d8b9254301
use simplified void_t for all compilers other than gcc 4.x (#2160) 2021-03-02 14:42:27 -08:00
Victor Zverovich
835b910e7d Add an is_formattable trait 2021-02-28 15:25:33 -08:00
Victor Zverovich
578874033a Revert "Optimize handling of integer constants" (#2147)
This reverts commit 2797588be1.
2021-02-25 05:58:58 -08:00
Jiahao XU
640acba850
Print x.what() of FMT_THROW when exception is disabled (#2145)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2021-02-24 06:29:04 -08:00
Alexey Ochapov
d8e1c9f175
fix fmt::get for some GCC versions and legacy Clang (#2144)
fixes https://github.com/fmtlib/fmt/issues/2140

- some GCC versions decay function pointers to `const void*`, exactly like
  MSVC does
- legacy Clang (prior to 7.0) treats function pointers also as `const T*`
  pointers, but unable to convert them
2021-02-23 07:18:30 -08:00
Victor Zverovich
2797588be1 Optimize handling of integer constants 2021-02-21 11:11:57 -08:00
Victor Zverovich
e8eff3b8fd Fix FMT_STATIC_THOUSANDS_SEPARATOR (#2142) 2021-02-21 07:42:12 -08:00
Alexey Ochapov
ab0f7d7fdc use const& for arguments 2021-02-20 11:50:12 -08:00
Alexey Ochapov
29cc8282b1 update chrono duration formatter (constness), use it in compile-test for specs checks 2021-02-20 11:50:12 -08:00
Alexey Ochapov
3f69af3aaf update wording in the error inside arg_id_handler, use FMT_ASSERT instead of throw 2021-02-20 11:50:12 -08:00
Alexey Ochapov
499047e132 fix incorrect indexing mode for named args, update tests 2021-02-20 11:50:12 -08:00
Alexey Ochapov
78c67157c1 prepare tests, fix incorrect handling of named args with simple {} replacement fields 2021-02-20 11:50:12 -08:00
Alexey Ochapov
b31bc2dc9f simplify try_format_argument(), make manual_indexing_id() a variable 2021-02-20 11:50:12 -08:00
Alexey Ochapov
95e1aa2dc5 add support for manual indexing and named fields, add tests 2021-02-20 11:50:12 -08:00
Victor Zverovich
7e72673d87 Improve width estimation (#2033) 2021-02-13 09:30:29 -08:00
Victor Zverovich
13b117b5bc Improve code point computation 2021-02-13 08:46:19 -08:00
Victor Zverovich
ee0fed639c Fix handling of the + flag with locales (#2133) 2021-02-13 07:08:01 -08:00
Yuval Gamzon-Kapeller
c5979d564e Fix fmt::localtime formatting not working in wide-char string contexts 2021-02-13 06:53:30 -08:00
Mike Crowe
e6ef927e6b
fmt::ptr: Support function pointers (#2131)
Passing a function pointer to fmt::ptr results in:

 In file included from /home/mac/git/fmt/test/gmock/gmock.h:238,
                  from /home/mac/git/fmt/test/format-test.cc:31:
 .../fmt/test/format-test.cc: In member function ‘virtual void FormatterTest_FormatPointer_Test::TestBody()’:
 .../fmt/test/format-test.cc:1486:56: error: no matching function for call to ‘ptr(void (&)(int, double, std::__cxx11::string))’
              format("{}", fmt::ptr(function_pointer_test)));

with GCC and Clang. Let's add an overload to support that usage.

Unfortunately, MSVC would
consider the overload to be ambiguous for unknown reasons:

 D:\a\fmt\fmt\test\format-test.cc(1485,1): error C2668: 'fmt::v7::ptr': ambiguous call to overloaded function [D:\a\fmt\build\test\format-test.vcxproj]
 D:\a\fmt\fmt\include\fmt/format.h(3742,60): message : could be 'const void *fmt::v7::ptr<void,int,double,std::string>(T (__cdecl *)(int,double,std::string))' [D:\a\fmt\build\test\format-test.vcxproj]
           with
           [
               T=void
           ]
 D:\a\fmt\fmt\include\fmt/format.h(3735,42): message : or       'const void *fmt::v7::ptr<void(int,double,std::string)>(T (__cdecl *))' [D:\a\fmt\build\test\format-test.vcxproj]
           with
           [
               T=void (int,double,std::string)
           ]
 D:\a\fmt\fmt\test\format-test.cc(1486,1): message : while trying to match the argument list '(overloaded-function)' [D:\a\fmt\build\test\format-test.vcxproj]

but luckily this means that the overload is unnecessary in that case
anyway, so we can just make it conditional.
2021-02-09 07:35:16 -08:00
Yin Zhong
1980ca8c4e
fix #2118: FMT_COMPILE did not work with tm formatter (#2119)
Co-authored-by: summivox <summivox@github.com>
2021-01-30 08:44:49 -08:00
Alexey Ochapov
2a25e2bf4d
Make ranges-test available with C++11 (#2114)
* make ranges-test available with C++11, fix problem with some gcc versions

* potentially fix build for MSVC 19.10, a bit reorganizing in test
2021-01-30 07:42:58 -08:00
Yin Zhong
b0b56b4379
fix #2116 (FMT_COMPILE requires exceptions enabled) (#2117)
Co-authored-by: summivox <summivox@github.com>
2021-01-28 06:58:49 -08:00
Victor Zverovich
ce519e939b Fix exception propagation from iterators (#2097) 2021-01-23 17:27:24 -08:00
Alexey Ochapov
acef0bb51a
use gcc-10.2 instead of gcc-10.1 on CI, also fix one problem (#2110)
the problem was not detected by test because of wrong gcc-10 minor version on CI
2021-01-23 07:52:41 -08:00
Ivan Polyakov
8bf28e6bb1
Add support for s format specifier to bool (#2094) (#2109) 2021-01-23 07:32:41 -08:00
Walter Gray
456efa4666
add missing detail namespace (#2107)
Co-authored-by: Walter Gray <walter.gray@getcruise.com>
2021-01-19 17:44:15 -08:00
Ivan Shynkarenka
80dc7cceb8
Fixed format.h(1465): warning C4702: unreachable code (#2106)
* Fixed format.h(1465): warning C4702: unreachable code

* Fixed format.h(1416): warning C4702: unreachable code
2021-01-19 17:13:10 -08:00
Victor Zverovich
7fd535c6ae Cleanup 'L' handling 2021-01-18 07:57:38 -08:00
Victor Zverovich
e4f2cf455e Make 'L' a modifier 2021-01-17 09:28:46 -08:00
Victor Zverovich
532e846b86 Fix width computation in float formatter 2021-01-15 11:07:55 -08:00
Victor Zverovich
f8c2f8480a Fix handling of width when formatting int as char 2021-01-14 08:41:17 -08:00
Victor Zverovich
0fe0b15e71 Fix handling of # in width computation 2021-01-13 16:48:07 -08:00
Victor Zverovich
061e364b25 Document output_file 2021-01-09 07:18:56 -08:00
Victor Zverovich
9ec5592bb5 Fix writing to stdout when redirected to NUL on Windows (#2080) 2020-12-30 13:23:37 -08:00
Alexey Ochapov
cdc5ef6710
Remove fallback to inline specifier from FMT_CONSTEXPR(20) macro (#2075) 2020-12-30 06:23:20 -08:00
Victor Zverovich
c9dd1eb97d Don't change charset 2020-12-27 07:44:02 -08:00
Alexey Ochapov
d09b5c1453
Fix std::byte formatting with compile-time API (#2072)
* add test for byte formatting with `FMT_COMPILE`

* fix byte formatting with `FMT_COMPILE`, use `__cpp_lib_byte` macro

* use is not custom mapped type check

* workaround MSVC bug
2020-12-27 07:23:28 -08:00
Alexey Ochapov
bbd6ed5bc5
Add support of most format_specs for formatting at compile-time (#2056) 2020-12-25 06:40:03 -08:00
Victor Zverovich
1256541d7a Fix formatting 2020-12-24 07:07:15 -08:00
Walter Gray
4fa4c9248f
Add tests for FMT_ENFORCE_COMPILE_STRING, fix several errors (#2038) 2020-12-24 06:40:46 -08:00
Issam Maghni
aa89e380d9
add cwchar to format.h for std::fputws (#2073) 2020-12-23 07:02:25 -08:00
Björn Schäpers
5a37e182de
Disable warning about format string (#2067)
Reported by MinGW/GCC 10
2020-12-21 08:43:30 -08:00
Daumantas Kavolis
fa43fd1444
Forward arguments to work with views (#2068) 2020-12-20 07:14:54 -08:00
Victor Zverovich
3551f5d118 Workaround a gcc 10 -Warray-bounds bug (#2065) 2020-12-19 09:34:43 -08:00
Victor Zverovich
e737672614 Remove an old mingw workaround (#2059) 2020-12-10 06:36:04 -08:00
Finkman
9293f7072e
Suppress gcc warning on privates-only class (#2053)
Since gcc 9 it warns about is_streamable to have only private methods.
Add explicit default ctor instead of suppression
2020-12-09 06:55:17 -08:00
Camille Bordignon
c20874c28f
Reenable support for fallback formatter in join (#2040) (#2050) 2020-12-08 08:56:53 -08:00
Alexey Ochapov
5de0bc1d4f
Add UDL as replacement for FMT_COMPILE (#2043) 2020-12-07 15:53:11 -08:00
Victor Zverovich
33f9a6d360 Fix handling of enums in to_string (#2036) 2020-12-03 15:18:33 -08:00
Victor Zverovich
1f4a76d2c8 Add a missing include (#2047) 2020-12-03 14:17:09 -08:00
Victor Zverovich
4a6eadbde0 Make std::byte formattabe (#1981) 2020-12-03 08:59:07 -08:00
Alexey Ochapov
683a74501f
fix formatting with empty compiled format string (#2042) 2020-12-02 07:14:57 -08:00
Victor Zverovich
5a493560f5 Move some code from core.h to format.h where it is used 2020-11-29 09:45:15 -08:00
Alexey Ochapov
dac753b81e
Basics of formatting at compile-time based on compile-time API (#2019) 2020-11-29 08:59:11 -08:00
Victor Zverovich
119f7dc3d6 Truncate file by default 2020-11-27 08:15:14 -08:00
Victor Zverovich
22a68d1613 Don't emit trailing zeros by default 2020-11-27 07:45:54 -08:00
Victor Zverovich
3f4839ce3d Merge branch 'release' of github.com:fmtlib/fmt 2020-11-25 06:41:05 -08:00
Victor Zverovich
0683fa7d1d Bump version 2020-11-24 08:36:21 -08:00
Victor Zverovich
58992761cf Reintroduce ostream support to range formatters (#2014) 2020-11-24 08:22:29 -08:00
Victor Zverovich
b8957f50c3 Fix an overflow in format_to_n (#2029) 2020-11-24 08:22:12 -08:00
Victor Zverovich
df66516ed3 Workaround an issue with mixing std versions in gcc (#2017) 2020-11-24 08:21:10 -08:00
Victor Zverovich
a57baa69a5 Fix more linkage errors (#2011) 2020-11-24 08:17:31 -08:00
Victor Zverovich
85534a1397 Fix linkage errors when linking with a shared library (#2011) 2020-11-24 08:15:59 -08:00
Victor Zverovich
cd3003683d Fix more linkage errors (#2011) 2020-11-23 10:34:27 -08:00
Victor Zverovich
d1ef29d679 Fix initialization of iterator_buffer (#1996) 2020-11-23 10:28:35 -08:00
Victor Zverovich
5f41bb0f77 clang-format 2020-11-23 10:23:54 -08:00
Victor Zverovich
a036cc97b7 Reintroduce ostream support to range formatters (#2014) 2020-11-21 16:31:22 -08:00
Victor Zverovich
2c734c9bca Fix an overflow in format_to_n (#2029) 2020-11-18 06:50:43 -08:00
Victor Zverovich
bcc20b29df Implement compile-time checks by default 2020-11-15 17:24:36 -08:00
Walter Gray
befd7d4a2f
Always use FMT_STRING internally where possible [Issue #2002] (#2006)
Co-authored-by: Walter Gray <walter.gray@getcruise.com>
2020-11-15 05:19:06 -08:00
Victor Zverovich
f81c14aa1e Workaround an issue with mixing std versions in gcc (#2017) 2020-11-14 11:41:51 -08:00
Victor Zverovich
5555651ce0 Fix more linkage errors (#2011) 2020-11-14 06:06:10 -08:00
rimathia
b268f8815d
detail::write in one more place relevant to printf with long argument… (#2016) 2020-11-13 12:14:16 -08:00
rimathia
986fa00406
Printf get container (#1982)
* eliminate one case where basic_print_context would copy a string into a fmt::basic_memory_buffer character by character instead of using fmt::basic_memory_buffer::append

* use detail::write instead of re-implementing it

* use to_unsigned to avoid signedness conversion warnings
2020-11-12 08:37:04 -08:00
Victor Zverovich
7abc3c01e0 Suppress a useless warning (#2004) 2020-11-12 08:18:28 -08:00
Victor Zverovich
6d14f78115 Fix linkage errors when linking with a shared library (#2011) 2020-11-12 06:11:17 -08:00
Victor Zverovich
9534b9fe69 Refactor warning suppression 2020-11-12 05:45:36 -08:00
Victor Zverovich
60dc273513 Simplify on_text 2020-11-11 15:13:44 -08:00
Victor Zverovich
b5dac0f0f8 Reduce <algorithm> usage (#1998) 2020-11-11 09:12:15 -08:00
Jonathan Gopel
a07627b1f8
🐛 Implicit sign conversion warning in clang in c++17 and 20 modes (#2009)
Problem:
- On Apple clang version 11.0.3 (clang-1103.0.32.62) in C++17 and C++20
  mode, clang 11.0.0 in C++17 and C++20 mode, and clang 9.0.1 in C++17
  mode, the following error is generated:

    In file included from test/compile-test.cc:16:
    include/fmt/compile.h:518:25: error: implicit conversion changes signedness: 'long' to 'unsigned long' [-Werror,-Wsign-conversion]
      return {f, pos + (end - str.data()) + 1, ctx.next_arg_id()};
                     ~  ~~~~^~~~~~~~~~~~
    include/fmt/compile.h:538:31: note: in instantiation of function template specialization
          'fmt::v7::detail::parse_specs<int, char>' requested here
          constexpr auto result = parse_specs<id_type>(str, POS + 2, ID);
                                  ^
    include/fmt/compile.h:569:17: note: in instantiation of function template specialization
          'fmt::v7::detail::compile_format_string<fmt::v7::detail::type_list<int>, 0, 0, FMT_COMPILE_STRING>' requested here
            detail::compile_format_string<detail::type_list<Args...>, 0, 0>(
                    ^
    include/fmt/compile.h:648:37: note: in instantiation of function template specialization
          'fmt::v7::detail::compile<int, FMT_COMPILE_STRING, 0>' requested here
      constexpr auto compiled = detail::compile<Args...>(S());
                                        ^
    test/compile-test.cc:140:24: note: in instantiation of function template specialization
          'fmt::v7::format<FMT_COMPILE_STRING, int, 0>' requested here
      EXPECT_EQ("42", fmt::format(FMT_COMPILE("{:x}"), 0x42));
                           ^
    In file included from test/compile-test.cc:16:
    include/fmt/compile.h:518:25: error: implicit conversion changes signedness: 'long' to 'unsigned long' [-Werror,-Wsign-conversion]
      return {f, pos + (end - str.data()) + 1, ctx.next_arg_id()};
                     ~  ~~~~^~~~~~~~~~~~
    include/fmt/compile.h:538:31: note: in instantiation of function template specialization
          'fmt::v7::detail::parse_specs<char [4], char>' requested here
          constexpr auto result = parse_specs<id_type>(str, POS + 2, ID);
                                  ^
    include/fmt/compile.h:494:27: note: in instantiation of function template specialization
          'fmt::v7::detail::compile_format_string<fmt::v7::detail::type_list<int, int, char const (&)[4], int>, 5, 2, FMT_COMPILE_STRING>'
          requested here
        constexpr auto tail = compile_format_string<Args, POS, ID>(format_str);
                              ^
    include/fmt/compile.h:539:14: note: in instantiation of function template specialization
          'fmt::v7::detail::parse_tail<fmt::v7::detail::type_list<int, int, char const (&)[4], int>, 5, 2, fmt::v7::detail::spec_field<char, int, 0>, FMT_COMPILE_STRING>' requested here
          return parse_tail<Args, result.end, result.next_arg_id>(
                 ^
    include/fmt/compile.h:569:17: note: in instantiation of function template specialization
          'fmt::v7::detail::compile_format_string<fmt::v7::detail::type_list<int, int, char const (&)[4], int>, 0, 0, FMT_COMPILE_STRING>'
          requested here
            detail::compile_format_string<detail::type_list<Args...>, 0, 0>(
                    ^
    include/fmt/compile.h:648:37: note: in instantiation of function template specialization
          'fmt::v7::detail::compile<int, int, char const (&)[4], int, FMT_COMPILE_STRING, 0>' requested here
      constexpr auto compiled = detail::compile<Args...>(S());
                                        ^
    test/compile-test.cc:145:18: note: in instantiation of function template specialization
          'fmt::v7::format<FMT_COMPILE_STRING, int, int, char const (&)[4], int, 0>' requested here
                fmt::format(FMT_COMPILE("{:{}}{:{}}"), 42, 4, "foo", 5));
                     ^
    2 errors generated.

Solution:
- Explicitly cast the result of the subtraction to the (unsigned) outer
  type.

Co-authored-by: Jonathan Gopel <jgopel@quantlab.com>
2020-11-11 07:57:52 -08:00
Victor Zverovich
beb248b6ac Optimize handling of large format strings 2020-11-11 06:11:05 -08:00
Lieven de Cock
1936dddc3c
fix gcc warning of missing override (#2001)
Co-authored-by: Lieven de Cock <killerbot@linux-2x3u.suse>
2020-11-10 07:57:21 -08:00
Victor Zverovich
14f6bd0f4e Move one more headers to args.h 2020-11-09 20:35:03 -08:00
Victor Zverovich
e01d26e1a4 Optimize includes 2020-11-09 16:34:54 -08:00
rimathia
3302fd1088
use memchr for searching for '%' in printf format string (#1984) 2020-11-08 10:36:00 -08:00
Victor Zverovich
ffa0a0834a Use newer versions of Sphinx and Breathe 2020-11-08 09:46:27 -08:00
Victor Zverovich
5bedcb665b Fix initialization of iterator_buffer (#1996) 2020-11-08 08:08:55 -08:00
Victor Zverovich
2435ea4113 Workaround MSVC mess 2020-11-08 07:48:03 -08:00
Victor Zverovich
8c6215f5de Fix fmt/color.h 2020-11-08 07:24:07 -08:00
Victor Zverovich
10ebe6cb48 Document color 2020-11-08 07:18:01 -08:00
Victor Zverovich
4f7df299ea Improve docs 2020-11-08 05:40:39 -08:00
Victor Zverovich
8f2131cf2d Document chrono 2020-11-07 10:51:08 -08:00
Victor Zverovich
a30b279bad Apply clang-format and tweak comments 2020-11-04 17:17:23 -08:00
Alexey Ochapov
6a2495c840
-Wattributes visibility warning with some GCC versions (#1975) 2020-11-04 17:11:31 -08:00
Victor Zverovich
689081d832 Merge branch 'release' of github.com:fmtlib/fmt 2020-11-04 07:46:02 -08:00
Victor Zverovich
e4eb242ce8 Update changelog and bump version 2020-11-03 21:20:53 -08:00
Victor Zverovich
ce98e0c6a0 Fix fallback float formatter at assymetric bounds (#1976) 2020-11-03 21:18:04 -08:00
Victor Zverovich
6b7bfed40c Fix fallback float formatter at assymetric bounds (#1976) 2020-11-03 19:19:10 -08:00
Jonathan Gopel
e904e891bd 🎨 🐛 Rename all shadowed types and variables 2020-11-03 07:30:27 -08:00
darklukee
771292c328
Remove sizeof from unused variable silencer (#1974)
Using sizeof causes some compilers to complain:
'operand of sizeof is not a type, variable, or dereferenced pointer'

static_cast itself should be enough to silence unused variable warning

Co-authored-by: Łukasz Mitka <lukasz.mitka@aptiv.com>
2020-11-03 06:48:19 -08:00
Victor Zverovich
86bf6045c6 Merge branch 'release' of github.com:fmtlib/fmt 2020-11-02 06:27:49 -08:00
Victor Zverovich
5d3f0741e3 Update changelog and bump version 2020-11-01 06:28:06 -08:00
Victor Zverovich
563cbb6c21 Add a macro to workaround clang/gcc ABI incompatibility on ARM 2020-11-01 06:10:04 -08:00
Victor Zverovich
425778aa67 Fix ABI compatibility (#1961) 2020-11-01 06:09:31 -08:00
Tobias Hammer
69a84198b0 Remove accidental parenthesis (#1968)
fails only when FMT_BUILTIN_CTZLL is not defined
2020-11-01 06:09:25 -08:00
OptoCloud
5c04504932 Removed [-Wsign-conversion] warning in GCC 2020-11-01 06:09:11 -08:00
Victor Zverovich
28a8eae850 Cleanup 2020-11-01 06:08:50 -08:00
Владислав Щапов
236fea1f00 Workaround bugs in gcc 8 2020-11-01 06:08:28 -08:00
Victor Zverovich
e50ced88c6 Add a macro to workaround clang/gcc ABI incompatibility on ARM 2020-10-31 07:52:08 -07:00
Victor Zverovich
112755cf91 Remove FMT_SAFEBUFFERS (#1966) 2020-10-29 17:42:45 -07:00
Victor Zverovich
4081b2fe94 Fix ABI compatibility (#1961) 2020-10-29 11:29:47 -07:00
Tobias Hammer
2d9311e860
Remove accidental parenthesis (#1968)
fails only when FMT_BUILTIN_CTZLL is not defined
2020-10-29 07:08:06 -07:00
Vladislav Shchapov
97c8873214
Allocator::max_size support in basic_memory_buffer (#1960) 2020-10-29 06:17:00 -07:00
OptoCloud
bb68f6089b Removed [-Wsign-conversion] warning in GCC 2020-10-28 06:02:17 -07:00
kitegi
f4ca065cfb Range support 2020-10-28 05:35:37 -07:00
Victor Zverovich
7977c2b4d0 Cleanup 2020-10-27 07:19:28 -07:00
Владислав Щапов
e54eb67639 Workaround bugs in gcc 8 2020-10-27 06:11:31 -07:00
Victor Zverovich
df4bd60f42 Bump version 2020-10-25 10:43:03 -07:00
Victor Zverovich
530cf316b8 Point to the release, not dev documentation 2020-10-24 12:02:12 -07:00
Victor Zverovich
8de96817ce Woraround bugs in gcc 8 2020-10-22 07:33:32 -07:00
Victor Zverovich
47e167679a Simplify arg formatter 2020-10-21 19:04:02 -07:00
Victor Zverovich
f0a42346a4 Move parsing optimization one level up 2020-10-21 18:18:53 -07:00
Victor Zverovich
86287b8d56 Optimize common case in parse_format_specs 2020-10-21 17:16:58 -07:00
Victor Zverovich
0ecb3d1829 Optimize alignment parsing 2020-10-21 12:45:11 -07:00
Victor Zverovich
9755307842 Optimize format_uint 2020-10-21 08:19:21 -07:00
Victor Zverovich
7446818f98 Simplify vformat_to 2020-10-21 07:15:11 -07:00
darklukee
280b5612c0 Add option to force usage of inline namespaces
Detection of inline namespaces is imperfect as some compilers
don't provide __has_feature

This option allows to override it if needed.
2020-10-21 06:38:59 -07:00
Victor Zverovich
e57ec7d563 Merge vformat_to overloads 2020-10-20 17:39:50 -07:00
Victor Zverovich
2a3f4de3f4 Remove iterator_category 2020-10-20 16:44:49 -07:00
Victor Zverovich
27fdb4ead2 Unshadow floaty 2020-10-20 15:05:00 -07:00
Victor Zverovich
297e0bad8c Apply clang-format 2020-10-20 14:10:28 -07:00
Victor Zverovich
e3b4c22ec9 Simplify is_output_iterator 2020-10-20 14:09:57 -07:00
Victor Zverovich
da8278e1e3 Update changelog and bump version 2020-10-19 14:37:14 -07:00
Victor Zverovich
f468b203ad Avoid conversion from long long to size_t (#1935) 2020-10-18 09:25:33 -07:00
Victor Zverovich
20d4f2e836 Fix handling of weird character types when parsing sign (#1932) 2020-10-17 09:40:30 -07:00
Bart Siwek
271eff149f
Make classes derived from buffer<T> final to silence the virtual destructor warning. (#1937)
Co-authored-by: Bart Siwek <bsiwek@cisco.com>
2020-10-15 17:41:56 -07:00
Victor Zverovich
41d97e1ef4 Fix a UB on ridiculously large precision 2020-10-11 08:07:52 -07:00
MarcDirven
01c37e0a4b
Added check for -mbig-obj and ref qualifier check (#1929)
* Added check whether mingw has -mbig-obj flag
* Removed ref qualifiers
2020-10-11 07:49:54 -07:00
Victor Zverovich
a5e7e7db95 Fix handling of thousand separator (#1927) 2020-10-10 07:23:36 -07:00
Victor Zverovich
bf19051a9f Optimize floating point formatting 2020-10-09 15:29:56 -07:00
Victor Zverovich
3c13a88b14 Optimize floating point formatting 2020-10-09 11:01:01 -07:00
Victor Zverovich
f6d75c534c Refactor write_float 2020-10-09 09:11:39 -07:00
Victor Zverovich
e9c0b2d69e Merge write_float overloads 2020-10-08 20:00:38 -07:00
Victor Zverovich
7eddbfed53 Cleanup exponent handling in write_float 2020-10-07 15:58:43 -07:00
Victor Zverovich
b347b3023f Update dynamic_formatter comment (#1923) 2020-10-07 12:15:07 -07:00
Victor Zverovich
3541880efd Fix integer overflow when using max int precision 2020-10-07 11:27:02 -07:00
Victor Zverovich
a18b3fbbdc Fix fixed precision handling when rounding (#1917) 2020-10-07 07:42:23 -07:00
Victor Zverovich
b91d39f20b Get rid of float_writer 2020-10-05 06:34:04 -07:00
Victor Zverovich
b4b64b9cce Refactor float formatting 2020-10-04 14:44:25 -07:00
Victor Zverovich
712abe40f2 Workaround a bug in gcc 7.5 (#1912)
Thanks Martin Janzen.
2020-10-04 09:20:37 -07:00
Victor Zverovich
af8a180aed Make GetCachedPower test more precise 2020-10-04 08:00:47 -07:00
Kazantcev Andrey
a581e9e5d8
Fix warning C4018: '<=': signed/unsigned mismatch (#1908) 2020-10-02 06:30:57 -07:00
Victor Zverovich
575f401896 Simplify FP formatting and follow coding conventions 2020-09-30 06:36:17 -07:00
jk-jeon
6f3536f974
Move zero-check to an earlier branch (#1906) 2020-09-29 06:24:53 -07:00
Victor Zverovich
90ef46df0b Fix dragonbox integration 2020-09-28 18:10:46 -07:00
Victor Zverovich
3ae88147e2 Fix declaration 2020-09-28 06:50:09 -07:00
Victor Zverovich
6417952574 Improve dragonbox integration 2020-09-27 20:49:37 -07:00
Victor Zverovich
79694d424c Fix WriteConsole signature 2020-09-27 14:26:28 -07:00
Victor Zverovich
63e0c35412 Make dragonbox::to_decimal available in format.h 2020-09-27 07:27:44 -07:00
Victor Zverovich
762c33a964
Simplify windows handling (#1903) 2020-09-26 08:20:38 -07:00
Bernd Baumanns
253d63159f
Remove dependency on windows.h (#1900) 2020-09-26 07:03:16 -07:00
Victor Zverovich
c156093ffd Fix carry in fallback_format 2020-09-25 10:12:44 -07:00
moiwi
34179b3354
Update format.h (#1898) 2020-09-24 08:16:16 -07:00
Victor Zverovich
0651e4598b Minor tweaks to get_cached_power 2020-09-23 16:04:40 -07:00
Victor Zverovich
6c025520aa Test that max_k is correctly defined 2020-09-23 15:44:37 -07:00
Victor Zverovich
51f8d0cc21 Reuse log10_2_significand constant 2020-09-23 13:19:21 -07:00
Riccardo Ghetta (larix)
1305cbeb6f
Fix MSVC2019 error C2049 when compiling with /clr (#1897)
'fmt::v7': non-inline namespace cannot be reopened as inline
2020-09-23 09:55:41 -07:00
Victor Zverovich
2d4fde3a2e Don't emit trailing zero for consistency with std::format 2020-09-23 09:19:12 -07:00
Victor Zverovich
5fd89d50e4 Minor simplifications 2020-09-23 08:05:31 -07:00
Victor Zverovich
605ce5e429 Simplify divisible_by_power_of_2 2020-09-22 20:44:29 -07:00
Victor Zverovich
085171e7e6 Remove grisu_count_digits 2020-09-22 19:36:52 -07:00
Victor Zverovich
aa729bf25b Remove dead code 2020-09-22 16:58:02 -07:00
Victor Zverovich
aa2ddf9b86 Simplify Dragonbox integration 2020-09-22 16:20:40 -07:00
Victor Zverovich
c1654ce487 Simplify uint32_or_64_or_128_t definition 2020-09-22 15:08:37 -07:00
Victor Zverovich
33712dc07a Combine pragmas 2020-09-22 14:47:35 -07:00
Victor Zverovich
e5942ac9dd Tweak comments 2020-09-22 14:36:10 -07:00
Victor Zverovich
aae7a1338c Remove unused pragmas 2020-09-22 14:00:41 -07:00
jk-jeon
6bcde9aab2
https://github.com/fmtlib/fmt/pull/1882#issuecomment-696823912 (#1894) 2020-09-22 10:33:52 -07:00
Victor Zverovich
bb0db5e51e clang-format 2020-09-22 08:19:37 -07:00
Victor Zverovich
16410056bf Optimize copy_str for counting_iterator 2020-09-22 07:56:09 -07:00
mwinterb
2591ab91c3
MSVC optimizations for count_digits. (#1890)
Changed the clz implementations to use xor instead of subtraction so that when
count_digits "undoes" the BSR -> CLZ translation, the optimizer is more
willing to recognize the equivalence.
Changed the data array in bsr2log10 to static since otherwise MSVC generates
code to build the array every time the function is called.
2020-09-21 11:38:06 -07:00
jk-jeon
2e620ddbcd
Small improvements that should have zero to negligible impact on the runtime (#1887) 2020-09-20 09:34:44 -07:00
Victor Zverovich
2f7e08856b Disable range formatter if value type is not formattable (#1885) 2020-09-20 08:37:49 -07:00
rimathia
2696dc9273
add forgotten template argument to make_format_args which made some u… (#1877)
* add forgotten template argument to make_format_args which made some uses of FMT_COMPILE not work anymore after 54daa0864a, add more elaborate test cases to compile-test as regression tests

* fix old-style cast which gcc on travis thankfully doesn't accept anymore

* hopefully last forgotten (void*)
2020-09-20 06:51:11 -07:00
Victor Zverovich
0016da7ab3 Don't generate zeros and fix UB on huge precision 2020-09-19 16:01:43 -07:00
Victor Zverovich
ce3f76994a Merge intrinsic blocks 2020-09-19 07:54:45 -07:00
Junekey Jeon
3b6248f602 Change formatting 2020-09-19 07:23:41 -07:00
Junekey Jeon
2d9b1dd0ad Fix sign mismatch 2020-09-19 07:23:41 -07:00
Junekey Jeon
1f0600a23b Fix bug regarding FMT_SAFEBUFFERS 2020-09-19 07:23:41 -07:00
Junekey Jeon
2ecdbb986d Fix a bug in ctzll 2020-09-19 07:23:41 -07:00
Junekey Jeon
6f81ea151a Fix typo (and thus bug) 2020-09-19 07:23:41 -07:00
Junekey Jeon
0c8ffe9b0f Implement Dragonbox (first version) 2020-09-19 07:23:41 -07:00
jk-jeon
42699bf408
Fix msvc version of clz & clzll (#1880)
Change msvc version of clz & clzll to match __builtin_clz & _builtin_clzll
2020-09-18 11:07:01 -07:00
Axel Kohlmeyer
bc51a8df04
Disable fallthrough attributes for the Intel compilers on Linux and MacOS (#1879)
* Disable fallthrough attributes for the Intel compilers

On MacOS and Linux the Intel compilers may be identified as the
host compilers (Clang or GNU) but do not support the corresponding
compiler specific fallthrough attributes.

* Rearrange ifdef logic for excluding pre-C++17 fallthrough attributes

This puts Intel and PGI compilers into a separate group
and thus makes the intent and logic more obvious.
2020-09-18 09:57:00 -07:00
Jan Schwers
45da432d60 fix compiler warnings in public header files 2020-09-17 15:53:53 -07:00
jk-jeon
d55e61f120
Improve FMT_ALWAYS_INLINE (#1878)
1. FMT_ALWAYS_INLINE should imply inline; otherwise, there might be
   linkage problems
2. Add specialization for MSVC (__forceinline)
2020-09-17 15:21:17 -07:00
Victor Zverovich
7e6827521a Remove trailing zeros when using fallback formatter (#1873) 2020-09-17 08:16:21 -07:00
Victor Zverovich
1d696dc280 Handle exotic character types in compilation 2020-09-17 07:12:34 -07:00
Alexey Ochapov
f674434a67
Add format_to_n overload that accepts FMT_COMPILE (from #1767) (#1869)
* Add format_to_n overload that accepts FMT_COMPILE

* add FormatToNWithCompileMacro test into CompileTest

Co-authored-by: Dmitriy Kurkin <Dmitriy.Kurkin@itiviti.com>
2020-09-15 07:28:06 -07:00
Victor Zverovich
5b5a597198 Fix handling of wide alignment 2020-09-15 06:53:06 -07:00
Victor Zverovich
3813966497 Simplify fallback format 2020-09-13 11:27:34 -07:00
Victor Zverovich
dce8e49b4f Handle float in fallback formatter 2020-09-13 09:28:40 -07:00
Victor Zverovich
78b5944313 Spelling 2020-09-12 13:14:49 -07:00
Victor Zverovich
f233b56cdd Don't generate insignificant digits 2020-09-12 09:19:50 -07:00
Victor Zverovich
58a044be5d Use built-in FP formatter for any precision 2020-09-11 07:19:45 -07:00
Victor Zverovich
efe3694f15 Macro tweak and clang-format 2020-09-07 14:43:00 -07:00
Victor Zverovich
9f312fe87e Implement fallback FP formatting with given precision (#1526) 2020-09-07 09:34:30 -07:00
Victor Zverovich
86f0a7046e Fix formatting 2020-09-06 08:58:19 -07:00
Denis Blank
bff4d18efb Add color format_to overloads
* Fix variable size basic_memory_buffer colorization
* Fix an unused arguments warning on GCC that blocks the CI otherwise
* Ref #1842
* Ref #1593
2020-09-06 08:24:15 -07:00
Ivan Shynkarenka
f19b8885f2
Fixed a warning in mingw32/mingw64 (#1860) 2020-09-06 06:27:37 -07:00
Giovanni Cerretani
f8e00a084a
NOMINMAX not handled properly (#1855) 2020-09-03 09:45:47 -07:00
Victor Zverovich
6cccdc24bc Fix move constructor (#1844) 2020-09-01 08:48:56 -07:00
t-wiser
69902c1787
Allow use of <fcntl.h> in Linux when __has_include is not available (#1848) 2020-09-01 06:29:34 -07:00
t-wiser
1edd38b96e
Add append mode. (#1847) 2020-08-31 15:48:39 -07:00
Adam Burgess
f39e6fb617
Add formatters for chrono::time_point<system_clock> (#1837)
Add formatters for chrono::time_point and helper overloads for localtime/gmtime(time_point)
Fixes #1819
2020-08-28 07:41:38 -07:00
Victor Zverovich
77b627be20 Fix bogus MSVC warnings (#1825) 2020-08-26 12:33:54 -07:00
Alexander Lanin
c7e6d8afb0
Fix usage of override (#1836) 2020-08-23 11:01:46 -07:00
Victor Zverovich
92bff2fe2c Revert "Add missing includes"
This reverts commit 06895a7687.
2020-08-21 16:24:53 -07:00
Victor Zverovich
a0dcfbc57b Add ptr to docs 2020-08-21 06:54:05 -07:00
Alexey Ochapov
1651b2d433
Fix detail::write with fallback formatter (#1829)
* add support for fallback_formatter in detail::write

* add ToString test into OStreamTest

to check fmt::to_string() with class that has output stream operator

* add WithOstreamOperator test into CompileTest

to check fmt::format() with FMT_COMPILE() and class that has output stream operator

* use conditional_t inside detail::write instead of 2 overloads

* Revert "add WithOstreamOperator test into CompileTest"

* remove Context from template parameters in detail::write
2020-08-20 06:41:09 -07:00
Victor Zverovich
06895a7687 Add missing includes 2020-08-19 20:33:04 -07:00
Victor Zverovich
92a448a071 Apply clang-format 2020-08-19 10:42:22 -07:00
Barry Revzin
6be6544668
Fixing buffer_appender's ++ slicing (#1822)
* Fixing buffer_appender's ++ slicing.

* This test requires C++14.

* Removing string_view dependency.

* Simplifying test case.

* Adding message to static_assert
2020-08-18 12:37:56 -07:00
Greg Sjaardema
76e97dc4df
Eliminate shadowed variable warnings on intel (#1816)
The intel-19 compiler warns about hidden variables:
```
/s/dev/nightly/libraries/ioss/src/fmt/format.h(2689): warning #1599: declaration hides variable "begin" (declared at line 2668)
      FMT_CONSTEXPR void operator()(const Char* begin, const Char* end) {
                                                ^
          detected during:
            instantiation of "Context::iterator fmt::v7::vformat_to<ArgFormatter,Char,Context>(ArgFormatter::iterator, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<Context>, fmt::v7::detail::locale_ref) [with ArgFormatter=fmt::v7::detail::arg_formatter<fmt::v7::detail::buffer_appender<char>, char>, Char=char, Context=fmt::v7::format_context]" at line 3492
            instantiation of "fmt::v7::detail::buffer_appender<Char> fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<Char> &, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char>>, fmt::v7::type_identity_t<Char>>>) [with Char=char]" at line 1413 of "/s/dev/nightly/libraries/ioss/src/fmt/format-inl.h"

/s/dev/nightly/libraries/ioss/src/fmt/format.h(2689): warning #1599: declaration hides variable "end" (declared at line 2669)
      FMT_CONSTEXPR void operator()(const Char* begin, const Char* end) {
                                                                   ^
          detected during:
            instantiation of "Context::iterator fmt::v7::vformat_to<ArgFormatter,Char,Context>(ArgFormatter::iterator, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<Context>, fmt::v7::detail::locale_ref) [with ArgFormatter=fmt::v7::detail::arg_formatter<fmt::v7::detail::buffer_appender<char>, char>, Char=char, Context=fmt::v7::format_context]" at line 3492
            instantiation of "fmt::v7::detail::buffer_appender<Char> fmt::v7::detail::vformat_to(fmt::v7::detail::buffer<Char> &, fmt::v7::basic_string_view<Char>, fmt::v7::basic_format_args<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<fmt::v7::type_identity_t<Char>>, fmt::v7::type_identity_t<Char>>>) [with Char=char]" at line 1413 of "/s/dev/nightly/libraries/ioss/src/fmt/format-inl.h"
```
Rename the second set of variables to `pbegin` and `pend` to eliminate warning.
2020-08-13 18:58:31 -07:00
Greg Sjaardema
e204df0e66
nvcc compiler should be EDG-based, but fails test (#1818)
Our nvcc compilers (10.1.243 and 9.2.X) do not define the correct value for `FMT_USE_UDL_TEMPLATE` and then end up with an error later on in the build.  Explicitly search for `__NVCC__` symbol not being defined.   Might want to instead use `FMT_NVCC` or some other check, but the raw `__EDG_VERSION__` check is not working correctly for nvcc.
2020-08-13 15:18:57 -07:00
medithe
1c8bb54703
small changes to reduce clang-9 warnings (#1808)
* include/fmt/format.h: int_writer: removed unnecessary iterator type re-declaration (prevents shadow-waringing in clang)

* include/fmt/format.h: int_writer: correctly cast signed integer to unsigned to prevent 'implicit conversion changes signedness'-warnings in clang.

Co-authored-by: Martin Wührer <martin.wuehrer@artech.at>
2020-08-13 11:56:03 -07:00
Seokjin Lee
4b69c78751
fix: warning C4100: unreferenced formal parameter (#1814)
Add [[maybe_unused]] to fix it.
2020-08-12 06:57:22 -07:00
n16h7hunt3r
fb0aeb8209
fix: disabled UDL templates for PGI (#1811) (#1812)
* fix: disabled UDL templates for PGI (#1811)

* fix: insert defined auround __PGI

Co-authored-by: n16h7hunt3r <n16h7hunt3r@nixos>
2020-08-11 15:27:27 -07:00
Victor Zverovich
54daa0864a Add dynamic width support to FMT_COMPILE (#1809) 2020-08-10 09:40:11 -07:00
Victor Zverovich
6fb7c6fb25 Workaround a bug in gcc10 (#1810) 2020-08-10 07:20:34 -07:00
Victor Zverovich
4fd95e4b4d Don't remove trailing zeros with # 2020-08-08 08:14:39 -07:00
Victor Zverovich
e06ae32294 Avoid warnings on functions with external linkage that don't have declarations 2020-08-08 07:58:13 -07:00
Victor Zverovich
7fc3d1f54c Add override to grow 2020-08-08 07:23:11 -07:00
Victor Zverovich
065889a593 Use correct capacity in iterator_buffer (#1807) 2020-08-08 07:01:21 -07:00
Barry Revzin
d0dd678693 Adding convenience append(range) 2020-08-08 06:33:46 -07:00
Victor Zverovich
c13f79e09e Merge release branch 2020-08-07 07:01:21 -07:00
Victor Zverovich
1ebc2f7cc6 Bump version 2020-08-06 07:41:04 -07:00
Victor Zverovich
0907c08ae5 Fix handling of default alignmment with locale (#1801) 2020-08-06 07:39:09 -07:00
Kingcom
37c8f4eaf3 Don't use 128 bit integers with clang-cl (#1800)
clang-cl currently has a long-standing bug that using 128 bit integers
generates references to symbols that are provided neither by its own nor
by the Microsoft runtime: https://bugs.llvm.org/show_bug.cgi?id=25305
2020-08-06 07:38:57 -07:00
Victor Zverovich
eaaaec9992 Workaround a bug in msvc 2020-08-06 07:38:51 -07:00
Victor Zverovich
ccf8561cb3 Workaround broken numeric_limites, part 2 (#1787) 2020-08-06 07:38:32 -07:00
Victor Zverovich
0cc73ebf79 Report error on missing named argument (#1796) 2020-08-06 07:38:18 -07:00
Victor Zverovich
33efc3c94f Fix handling of iterators in locale-specific formatting (#1782) 2020-08-06 07:38:08 -07:00
medithe
717b226b59
include/fmt/format.h: explicit cast to std::size_t for parameter to buffer.resize() in order to get rid of warning 'implicit conversion changes signedness:' in clang-8 (#1802)
Co-authored-by: Martin Wührer <martin.wuehrer@artech.at>
2020-08-05 09:37:10 -07:00
Victor Zverovich
2a69f56769 Tweak buffer size 2020-08-05 08:22:12 -07:00
Victor Zverovich
ea76933802 Simplify ostream 2020-08-04 20:11:43 -07:00
Victor Zverovich
5413713c95 Remove unused function 2020-08-04 19:08:06 -07:00
Victor Zverovich
57f462428d Increase the default buffer size 2020-08-04 08:19:19 -07:00
Victor Zverovich
e587adb4e9 Simplify count_digits 2020-08-03 15:45:48 -07:00