1# 10.2.0 - 2024-01-01 2 3- Added support for the `%j` specifier (the number of days) for 4 `std::chrono::duration` (https://github.com/fmtlib/fmt/issues/3643, 5 https://github.com/fmtlib/fmt/pull/3732). Thanks @intelfx. 6 7- Added support for the chrono suffix for days and changed 8 the suffix for minutes from "m" to the correct "min" 9 (https://github.com/fmtlib/fmt/issues/3662, 10 https://github.com/fmtlib/fmt/pull/3664). 11 For example ([godbolt](https://godbolt.org/z/9KhMnq9ba)): 12 13 ```c++ 14 #include <fmt/chrono.h> 15 16 int main() { 17 fmt::print("{}\n", std::chrono::days(42)); // prints "42d" 18 } 19 ``` 20 21 Thanks @Richardk2n. 22 23- Fixed an overflow in `std::chrono::time_point` formatting with large dates 24 (https://github.com/fmtlib/fmt/issues/3725, 25 https://github.com/fmtlib/fmt/pull/3727). Thanks @cschreib. 26 27- Added a formatter for `std::source_location` 28 (https://github.com/fmtlib/fmt/pull/3730). 29 For example ([godbolt](https://godbolt.org/z/YajfKjhhr)): 30 31 ```c++ 32 #include <source_location> 33 #include <fmt/std.h> 34 35 int main() { 36 fmt::print("{}\n", std::source_location::current()); 37 } 38 ``` 39 40 prints 41 42 ``` 43 /app/example.cpp:5:51: int main() 44 ``` 45 46 Thanks @felix642. 47 48- Added a formatter for `std::bitset` 49 (https://github.com/fmtlib/fmt/pull/3660). 50 For example ([godbolt](https://godbolt.org/z/bdEaGeYxe)): 51 52 ```c++ 53 #include <bitset> 54 #include <fmt/std.h> 55 56 int main() { 57 fmt::print("{}\n", std::bitset<6>(42)); // prints "101010" 58 } 59 ``` 60 61 Thanks @muggenhor. 62 63- Added an experimental `nested_formatter` that provides an easy way of 64 applying a formatter to one or more subobjects while automatically handling 65 width, fill and alignment. For example: 66 67 ```c++ 68 #include <fmt/format.h> 69 70 struct point { 71 double x, y; 72 }; 73 74 template <> 75 struct fmt::formatter<point> : nested_formatter<double> { 76 auto format(point p, format_context& ctx) const { 77 return write_padded(ctx, [=](auto out) { 78 return format_to(out, "({}, {})", nested(p.x), nested(p.y)); 79 }); 80 } 81 }; 82 83 int main() { 84 fmt::print("[{:>20.2f}]", point{1, 2}); 85 } 86 ``` 87 88 prints 89 90 ``` 91 [ (1.00, 2.00)] 92 ``` 93 94- Added the generic representation (`g`) to `std::filesystem::path` 95 (https://github.com/fmtlib/fmt/issues/3715, 96 https://github.com/fmtlib/fmt/pull/3729). For example: 97 98 ```c++ 99 #include <filesystem> 100 #include <fmt/std.h> 101 102 int main() { 103 fmt::print("{:g}\n", std::filesystem::path("C:\\foo")); 104 } 105 ``` 106 107 prints `"C:/foo"` on Windows. 108 109 Thanks @js324. 110 111- Made `format_as` work with references 112 (https://github.com/fmtlib/fmt/pull/3739). Thanks @tchaikov. 113 114- Fixed formatting of invalid UTF-8 with precision 115 (https://github.com/fmtlib/fmt/issues/3284). 116 117- Fixed an inconsistency between `fmt::to_string` and `fmt::format` 118 (https://github.com/fmtlib/fmt/issues/3684). 119 120- Disallowed unsafe uses of `fmt::styled` 121 (https://github.com/fmtlib/fmt/issues/3625): 122 123 ```c++ 124 auto s = fmt::styled(std::string("dangle"), fmt::emphasis::bold); 125 fmt::print("{}\n", s); // compile error 126 ``` 127 128 Pass `fmt::styled(...)` as a parameter instead. 129 130- Added a null check when formatting a C string with the `s` specifier 131 (https://github.com/fmtlib/fmt/issues/3706). 132 133- Disallowed the `c` specifier for `bool` 134 (https://github.com/fmtlib/fmt/issues/3726, 135 https://github.com/fmtlib/fmt/pull/3734). Thanks @js324. 136 137- Made the default formatting unlocalized in `fmt::ostream_formatter` for 138 consistency with the rest of the library 139 (https://github.com/fmtlib/fmt/issues/3460). 140 141- Fixed localized formatting in bases other than decimal 142 (https://github.com/fmtlib/fmt/issues/3693, 143 https://github.com/fmtlib/fmt/pull/3750). Thanks @js324. 144 145- Fixed a performance regression in experimental `fmt::ostream::print` 146 (https://github.com/fmtlib/fmt/issues/3674). 147 148- Added synchronization with the underlying output stream when writing to 149 the Windows console 150 (https://github.com/fmtlib/fmt/pull/3668, 151 https://github.com/fmtlib/fmt/issues/3688, 152 https://github.com/fmtlib/fmt/pull/3689). 153 Thanks @Roman-Koshelev and @dimztimz. 154 155- Changed to only export `format_error` when {fmt} is built as a shared 156 library (https://github.com/fmtlib/fmt/issues/3626, 157 https://github.com/fmtlib/fmt/pull/3627). Thanks @phprus. 158 159- Made `fmt::streamed` `constexpr`. 160 (https://github.com/fmtlib/fmt/pull/3650). Thanks @muggenhor. 161 162- Enabled `consteval` on older versions of MSVC 163 (https://github.com/fmtlib/fmt/pull/3757). Thanks @phprus. 164 165- Added an option to build without `wchar_t` support on Windows 166 (https://github.com/fmtlib/fmt/issues/3631, 167 https://github.com/fmtlib/fmt/pull/3636). Thanks @glebm. 168 169- Improved build and CI configuration 170 (https://github.com/fmtlib/fmt/pull/3679, 171 https://github.com/fmtlib/fmt/issues/3701, 172 https://github.com/fmtlib/fmt/pull/3702, 173 https://github.com/fmtlib/fmt/pull/3749). 174 Thanks @jcar87, @pklima and @tchaikov. 175 176- Fixed various warnings, compilation and test issues 177 (https://github.com/fmtlib/fmt/issues/3607, 178 https://github.com/fmtlib/fmt/pull/3610, 179 https://github.com/fmtlib/fmt/pull/3624, 180 https://github.com/fmtlib/fmt/pull/3630, 181 https://github.com/fmtlib/fmt/pull/3634, 182 https://github.com/fmtlib/fmt/pull/3638, 183 https://github.com/fmtlib/fmt/issues/3645, 184 https://github.com/fmtlib/fmt/issues/3646, 185 https://github.com/fmtlib/fmt/pull/3647, 186 https://github.com/fmtlib/fmt/pull/3652, 187 https://github.com/fmtlib/fmt/issues/3654, 188 https://github.com/fmtlib/fmt/pull/3663, 189 https://github.com/fmtlib/fmt/issues/3670, 190 https://github.com/fmtlib/fmt/pull/3680, 191 https://github.com/fmtlib/fmt/issues/3694, 192 https://github.com/fmtlib/fmt/pull/3695, 193 https://github.com/fmtlib/fmt/pull/3699, 194 https://github.com/fmtlib/fmt/issues/3705, 195 https://github.com/fmtlib/fmt/issues/3710, 196 https://github.com/fmtlib/fmt/issues/3712, 197 https://github.com/fmtlib/fmt/pull/3713, 198 https://github.com/fmtlib/fmt/issues/3714, 199 https://github.com/fmtlib/fmt/pull/3716, 200 https://github.com/fmtlib/fmt/pull/3723, 201 https://github.com/fmtlib/fmt/issues/3738, 202 https://github.com/fmtlib/fmt/issues/3740, 203 https://github.com/fmtlib/fmt/pull/3741, 204 https://github.com/fmtlib/fmt/pull/3743, 205 https://github.com/fmtlib/fmt/issues/3745, 206 https://github.com/fmtlib/fmt/pull/3747, 207 https://github.com/fmtlib/fmt/pull/3748, 208 https://github.com/fmtlib/fmt/pull/3751, 209 https://github.com/fmtlib/fmt/pull/3754, 210 https://github.com/fmtlib/fmt/pull/3755, 211 https://github.com/fmtlib/fmt/issues/3760, 212 https://github.com/fmtlib/fmt/pull/3762, 213 https://github.com/fmtlib/fmt/issues/3763, 214 https://github.com/fmtlib/fmt/pull/3764, 215 https://github.com/fmtlib/fmt/issues/3774, 216 https://github.com/fmtlib/fmt/pull/3779). 217 Thanks @danakj, @vinayyadav3016, @cyyever, @phprus, @qimiko, @saschasc, 218 @gsjaardema, @lazka, @Zhaojun-Liu, @carlsmedstad, @hotwatermorning, 219 @cptFracassa, @kuguma, @PeterJohnson, @H1X4Dev, @asantoni, @eltociear, 220 @msimberg, @tchaikov, @waywardmonkeys. 221 222- Improved documentation and README 223 (https://github.com/fmtlib/fmt/issues/2086, 224 https://github.com/fmtlib/fmt/issues/3637, 225 https://github.com/fmtlib/fmt/pull/3642, 226 https://github.com/fmtlib/fmt/pull/3653, 227 https://github.com/fmtlib/fmt/pull/3655, 228 https://github.com/fmtlib/fmt/pull/3661, 229 https://github.com/fmtlib/fmt/issues/3673, 230 https://github.com/fmtlib/fmt/pull/3677, 231 https://github.com/fmtlib/fmt/pull/3737, 232 https://github.com/fmtlib/fmt/issues/3742, 233 https://github.com/fmtlib/fmt/pull/3744). 234 Thanks @idzm, @perlun, @joycebrum, @fennewald, @reinhardt1053, @GeorgeLS. 235 236- Updated CI dependencies 237 (https://github.com/fmtlib/fmt/pull/3615, 238 https://github.com/fmtlib/fmt/pull/3622, 239 https://github.com/fmtlib/fmt/pull/3623, 240 https://github.com/fmtlib/fmt/pull/3666, 241 https://github.com/fmtlib/fmt/pull/3696, 242 https://github.com/fmtlib/fmt/pull/3697, 243 https://github.com/fmtlib/fmt/pull/3759, 244 https://github.com/fmtlib/fmt/pull/3782). 245 246# 10.1.1 - 2023-08-28 247 248- Added formatters for `std::atomic` and `atomic_flag` 249 (https://github.com/fmtlib/fmt/pull/3574, 250 https://github.com/fmtlib/fmt/pull/3594). 251 Thanks @wangzw and @AlexGuteniev. 252- Fixed an error about partial specialization of `formatter<string>` 253 after instantiation when compiled with gcc and C++20 254 (https://github.com/fmtlib/fmt/issues/3584). 255- Fixed compilation as a C++20 module with gcc and clang 256 (https://github.com/fmtlib/fmt/issues/3587, 257 https://github.com/fmtlib/fmt/pull/3597, 258 https://github.com/fmtlib/fmt/pull/3605). 259 Thanks @MathewBensonCode. 260- Made `fmt::to_string` work with types that have `format_as` 261 overloads (https://github.com/fmtlib/fmt/pull/3575). Thanks @phprus. 262- Made `formatted_size` work with integral format specifiers at 263 compile time (https://github.com/fmtlib/fmt/pull/3591). 264 Thanks @elbeno. 265- Fixed a warning about the `no_unique_address` attribute on clang-cl 266 (https://github.com/fmtlib/fmt/pull/3599). Thanks @lukester1975. 267- Improved compatibility with the legacy GBK encoding 268 (https://github.com/fmtlib/fmt/issues/3598, 269 https://github.com/fmtlib/fmt/pull/3599). Thanks @YuHuanTin. 270- Added OpenSSF Scorecard analysis 271 (https://github.com/fmtlib/fmt/issues/3530, 272 https://github.com/fmtlib/fmt/pull/3571). Thanks @joycebrum. 273- Updated CI dependencies 274 (https://github.com/fmtlib/fmt/pull/3591, 275 https://github.com/fmtlib/fmt/pull/3592, 276 https://github.com/fmtlib/fmt/pull/3593, 277 https://github.com/fmtlib/fmt/pull/3602). 278 279# 10.1.0 - 2023-08-12 280 281- Optimized format string compilation resulting in up to 40% speed up 282 in compiled `format_to` and \~4x speed up in compiled `format_to_n` 283 on a concatenation benchmark 284 (https://github.com/fmtlib/fmt/issues/3133, 285 https://github.com/fmtlib/fmt/issues/3484). 286 287 {fmt} 10.0: 288 289 --------------------------------------------------------- 290 Benchmark Time CPU Iterations 291 --------------------------------------------------------- 292 BM_format_to 78.9 ns 78.9 ns 8881746 293 BM_format_to_n 568 ns 568 ns 1232089 294 295 {fmt} 10.1: 296 297 --------------------------------------------------------- 298 Benchmark Time CPU Iterations 299 --------------------------------------------------------- 300 BM_format_to 54.9 ns 54.9 ns 12727944 301 BM_format_to_n 133 ns 133 ns 5257795 302 303- Optimized storage of an empty allocator in `basic_memory_buffer` 304 (https://github.com/fmtlib/fmt/pull/3485). Thanks @Minty-Meeo. 305 306- Added formatters for proxy references to elements of 307 `std::vector<bool>` and `std::bitset<N>` 308 (https://github.com/fmtlib/fmt/issues/3567, 309 https://github.com/fmtlib/fmt/pull/3570). For example 310 ([godbolt](https://godbolt.org/z/zYb79Pvn8)): 311 312 ```c++ 313 #include <vector> 314 #include <fmt/std.h> 315 316 int main() { 317 auto v = std::vector<bool>{true}; 318 fmt::print("{}", v[0]); 319 } 320 ``` 321 322 Thanks @phprus and @felix642. 323 324- Fixed an ambiguous formatter specialization for containers that look 325 like container adaptors such as `boost::flat_set` 326 (https://github.com/fmtlib/fmt/issues/3556, 327 https://github.com/fmtlib/fmt/pull/3561). Thanks @5chmidti. 328 329- Fixed compilation when formatting durations not convertible from 330 `std::chrono::seconds` 331 (https://github.com/fmtlib/fmt/pull/3430). Thanks @patlkli. 332 333- Made the `formatter` specialization for `char*` const-correct 334 (https://github.com/fmtlib/fmt/pull/3432). Thanks @timsong-cpp. 335 336- Made `{}` and `{:}` handled consistently during compile-time checks 337 (https://github.com/fmtlib/fmt/issues/3526). 338 339- Disallowed passing temporaries to `make_format_args` to improve API 340 safety by preventing dangling references. 341 342- Improved the compile-time error for unformattable types 343 (https://github.com/fmtlib/fmt/pull/3478). Thanks @BRevzin. 344 345- Improved the floating-point formatter 346 (https://github.com/fmtlib/fmt/pull/3448, 347 https://github.com/fmtlib/fmt/pull/3450). 348 Thanks @florimond-collette. 349 350- Fixed handling of precision for `long double` larger than 64 bits. 351 (https://github.com/fmtlib/fmt/issues/3539, 352 https://github.com/fmtlib/fmt/issues/3564). 353 354- Made floating-point and chrono tests less platform-dependent 355 (https://github.com/fmtlib/fmt/issues/3337, 356 https://github.com/fmtlib/fmt/issues/3433, 357 https://github.com/fmtlib/fmt/pull/3434). Thanks @phprus. 358 359- Removed the remnants of the Grisu floating-point formatter that has 360 been replaced by Dragonbox in earlier versions. 361 362- Added `throw_format_error` to the public API 363 (https://github.com/fmtlib/fmt/pull/3551). Thanks @mjerabek. 364 365- Made `FMT_THROW` assert even if assertions are disabled when 366 compiling with exceptions disabled 367 (https://github.com/fmtlib/fmt/issues/3418, 368 https://github.com/fmtlib/fmt/pull/3439). Thanks @BRevzin. 369 370- Made `format_as` and `std::filesystem::path` formatter work with 371 exotic code unit types. 372 (https://github.com/fmtlib/fmt/pull/3457, 373 https://github.com/fmtlib/fmt/pull/3476). Thanks @gix and @hmbj. 374 375- Added support for the `?` format specifier to 376 `std::filesystem::path` and made the default unescaped for 377 consistency with strings. 378 379- Deprecated the wide stream overload of `printf`. 380 381- Removed unused `basic_printf_parse_context`. 382 383- Improved RTTI detection used when formatting exceptions 384 (https://github.com/fmtlib/fmt/pull/3468). Thanks @danakj. 385 386- Improved compatibility with VxWorks7 387 (https://github.com/fmtlib/fmt/pull/3467). Thanks @wenshan1. 388 389- Improved documentation 390 (https://github.com/fmtlib/fmt/issues/3174, 391 https://github.com/fmtlib/fmt/issues/3423, 392 https://github.com/fmtlib/fmt/pull/3454, 393 https://github.com/fmtlib/fmt/issues/3458, 394 https://github.com/fmtlib/fmt/pull/3461, 395 https://github.com/fmtlib/fmt/issues/3487, 396 https://github.com/fmtlib/fmt/pull/3515). 397 Thanks @zencatalyst, @rlalik and @mikecrowe. 398 399- Improved build and CI configurations 400 (https://github.com/fmtlib/fmt/issues/3449, 401 https://github.com/fmtlib/fmt/pull/3451, 402 https://github.com/fmtlib/fmt/pull/3452, 403 https://github.com/fmtlib/fmt/pull/3453, 404 https://github.com/fmtlib/fmt/pull/3459, 405 https://github.com/fmtlib/fmt/issues/3481, 406 https://github.com/fmtlib/fmt/pull/3486, 407 https://github.com/fmtlib/fmt/issues/3489, 408 https://github.com/fmtlib/fmt/pull/3496, 409 https://github.com/fmtlib/fmt/issues/3517, 410 https://github.com/fmtlib/fmt/pull/3523, 411 https://github.com/fmtlib/fmt/pull/3563). 412 Thanks @joycebrum, @glebm, @phprus, @petrmanek, @setoye and @abouvier. 413 414- Fixed various warnings and compilation issues 415 (https://github.com/fmtlib/fmt/issues/3408, 416 https://github.com/fmtlib/fmt/issues/3424, 417 https://github.com/fmtlib/fmt/issues/3444, 418 https://github.com/fmtlib/fmt/pull/3446, 419 https://github.com/fmtlib/fmt/pull/3475, 420 https://github.com/fmtlib/fmt/pull/3482, 421 https://github.com/fmtlib/fmt/issues/3492, 422 https://github.com/fmtlib/fmt/pull/3493, 423 https://github.com/fmtlib/fmt/pull/3508, 424 https://github.com/fmtlib/fmt/issues/3509, 425 https://github.com/fmtlib/fmt/issues/3533, 426 https://github.com/fmtlib/fmt/pull/3542, 427 https://github.com/fmtlib/fmt/issues/3543, 428 https://github.com/fmtlib/fmt/issues/3540, 429 https://github.com/fmtlib/fmt/pull/3544, 430 https://github.com/fmtlib/fmt/issues/3548, 431 https://github.com/fmtlib/fmt/pull/3549, 432 https://github.com/fmtlib/fmt/pull/3550, 433 https://github.com/fmtlib/fmt/pull/3552). 434 Thanks @adesitter, @hmbj, @Minty-Meeo, @phprus, @TobiSchluter, 435 @kieranclancy, @alexeedm, @jurihock, @Ozomahtli and @razaqq. 436 437# 10.0.0 - 2023-05-09 438 439- Replaced Grisu with a new floating-point formatting algorithm for 440 given precision (https://github.com/fmtlib/fmt/issues/3262, 441 https://github.com/fmtlib/fmt/issues/2750, 442 https://github.com/fmtlib/fmt/pull/3269, 443 https://github.com/fmtlib/fmt/pull/3276). The new algorithm 444 is based on Dragonbox already used for the shortest representation 445 and gives substantial performance improvement: 446 447  448 449 - Red: new algorithm 450 - Green: new algorithm with `FMT_USE_FULL_CACHE_DRAGONBOX` defined 451 to 1 452 - Blue: old algorithm 453 454 Thanks @jk-jeon. 455 456- Replaced `snprintf`-based hex float formatter with an internal 457 implementation (https://github.com/fmtlib/fmt/pull/3179, 458 https://github.com/fmtlib/fmt/pull/3203). This removes the 459 last usage of `s(n)printf` in {fmt}. Thanks @phprus. 460 461- Fixed alignment of floating-point numbers with localization 462 (https://github.com/fmtlib/fmt/issues/3263, 463 https://github.com/fmtlib/fmt/pull/3272). Thanks @ShawnZhong. 464 465- Made handling of `#` consistent with `std::format`. 466 467- Improved C++20 module support 468 (https://github.com/fmtlib/fmt/pull/3134, 469 https://github.com/fmtlib/fmt/pull/3254, 470 https://github.com/fmtlib/fmt/pull/3386, 471 https://github.com/fmtlib/fmt/pull/3387, 472 https://github.com/fmtlib/fmt/pull/3388, 473 https://github.com/fmtlib/fmt/pull/3392, 474 https://github.com/fmtlib/fmt/pull/3397, 475 https://github.com/fmtlib/fmt/pull/3399, 476 https://github.com/fmtlib/fmt/pull/3400). 477 Thanks @laitingsheng, @Orvid and @DanielaE. 478 479- Switched to the [modules CMake library](https://github.com/vitaut/modules) 480 which allows building {fmt} as a C++20 module with clang: 481 482 CXX=clang++ cmake -DFMT_MODULE=ON . 483 make 484 485- Made `format_as` work with any user-defined type and not just enums. 486 For example ([godbolt](https://godbolt.org/z/b7rqhq5Kh)): 487 488 ```c++ 489 #include <fmt/format.h> 490 491 struct floaty_mc_floatface { 492 double value; 493 }; 494 495 auto format_as(floaty_mc_floatface f) { return f.value; } 496 497 int main() { 498 fmt::print("{:8}\n", floaty_mc_floatface{0.42}); // prints " 0.42" 499 } 500 ``` 501 502- Removed deprecated implicit conversions for enums and conversions to 503 primitive types for compatibility with `std::format` and to prevent 504 potential ODR violations. Use `format_as` instead. 505 506- Added support for fill, align and width to the time point formatter 507 (https://github.com/fmtlib/fmt/issues/3237, 508 https://github.com/fmtlib/fmt/pull/3260, 509 https://github.com/fmtlib/fmt/pull/3275). For example 510 ([godbolt](https://godbolt.org/z/rKP6MGz6c)): 511 512 ```c++ 513 #include <fmt/chrono.h> 514 515 int main() { 516 // prints " 2023" 517 fmt::print("{:>8%Y}\n", std::chrono::system_clock::now()); 518 } 519 ``` 520 521 Thanks @ShawnZhong. 522 523- Implemented formatting of subseconds 524 (https://github.com/fmtlib/fmt/issues/2207, 525 https://github.com/fmtlib/fmt/issues/3117, 526 https://github.com/fmtlib/fmt/pull/3115, 527 https://github.com/fmtlib/fmt/pull/3143, 528 https://github.com/fmtlib/fmt/pull/3144, 529 https://github.com/fmtlib/fmt/pull/3349). For example 530 ([godbolt](https://godbolt.org/z/45738oGEo)): 531 532 ```c++ 533 #include <fmt/chrono.h> 534 535 int main() { 536 // prints 01.234567 537 fmt::print("{:%S}\n", std::chrono::microseconds(1234567)); 538 } 539 ``` 540 541 Thanks @patrickroocks @phprus and @BRevzin. 542 543- Added precision support to `%S` 544 (https://github.com/fmtlib/fmt/pull/3148). Thanks @SappyJoy 545 546- Added support for `std::utc_time` 547 (https://github.com/fmtlib/fmt/issues/3098, 548 https://github.com/fmtlib/fmt/pull/3110). Thanks @patrickroocks. 549 550- Switched formatting of `std::chrono::system_clock` from local time 551 to UTC for compatibility with the standard 552 (https://github.com/fmtlib/fmt/issues/3199, 553 https://github.com/fmtlib/fmt/pull/3230). Thanks @ned14. 554 555- Added support for `%Ez` and `%Oz` to chrono formatters. 556 (https://github.com/fmtlib/fmt/issues/3220, 557 https://github.com/fmtlib/fmt/pull/3222). Thanks @phprus. 558 559- Improved validation of format specifiers for `std::chrono::duration` 560 (https://github.com/fmtlib/fmt/issues/3219, 561 https://github.com/fmtlib/fmt/pull/3232). Thanks @ShawnZhong. 562 563- Fixed formatting of time points before the epoch 564 (https://github.com/fmtlib/fmt/issues/3117, 565 https://github.com/fmtlib/fmt/pull/3261). For example 566 ([godbolt](https://godbolt.org/z/f7bcznb3W)): 567 568 ```c++ 569 #include <fmt/chrono.h> 570 571 int main() { 572 auto t = std::chrono::system_clock::from_time_t(0) - 573 std::chrono::milliseconds(250); 574 fmt::print("{:%S}\n", t); // prints 59.750000000 575 } 576 ``` 577 578 Thanks @ShawnZhong. 579 580- Experimental: implemented glibc extension for padding seconds, 581 minutes and hours 582 (https://github.com/fmtlib/fmt/issues/2959, 583 https://github.com/fmtlib/fmt/pull/3271). Thanks @ShawnZhong. 584 585- Added a formatter for `std::exception` 586 (https://github.com/fmtlib/fmt/issues/2977, 587 https://github.com/fmtlib/fmt/issues/3012, 588 https://github.com/fmtlib/fmt/pull/3062, 589 https://github.com/fmtlib/fmt/pull/3076, 590 https://github.com/fmtlib/fmt/pull/3119). For example 591 ([godbolt](https://godbolt.org/z/8xoWGs9e4)): 592 593 ```c++ 594 #include <fmt/std.h> 595 #include <vector> 596 597 int main() { 598 try { 599 std::vector<bool>().at(0); 600 } catch(const std::exception& e) { 601 fmt::print("{}", e); 602 } 603 } 604 ``` 605 606 prints: 607 608 vector<bool>::_M_range_check: __n (which is 0) >= this->size() (which is 0) 609 610 on libstdc++. Thanks @zach2good and @phprus. 611 612- Moved `std::error_code` formatter from `fmt/os.h` to `fmt/std.h`. 613 (https://github.com/fmtlib/fmt/pull/3125). Thanks @phprus. 614 615- Added formatters for standard container adapters: 616 `std::priority_queue`, `std::queue` and `std::stack` 617 (https://github.com/fmtlib/fmt/issues/3215, 618 https://github.com/fmtlib/fmt/pull/3279). For example 619 ([godbolt](https://godbolt.org/z/74h1xY9qK)): 620 621 ```c++ 622 #include <fmt/ranges.h> 623 #include <stack> 624 #include <vector> 625 626 int main() { 627 auto s = std::stack<bool, std::vector<bool>>(); 628 for (auto b: {true, false, true}) s.push(b); 629 fmt::print("{}\n", s); // prints [true, false, true] 630 } 631 ``` 632 633 Thanks @ShawnZhong. 634 635- Added a formatter for `std::optional` to `fmt/std.h` 636 (https://github.com/fmtlib/fmt/issues/1367, 637 https://github.com/fmtlib/fmt/pull/3303). 638 Thanks @tom-huntington. 639 640- Fixed formatting of valueless by exception variants 641 (https://github.com/fmtlib/fmt/pull/3347). Thanks @TheOmegaCarrot. 642 643- Made `fmt::ptr` accept `unique_ptr` with a custom deleter 644 (https://github.com/fmtlib/fmt/pull/3177). Thanks @hmbj. 645 646- Fixed formatting of noncopyable ranges and nested ranges of chars 647 (https://github.com/fmtlib/fmt/pull/3158 648 https://github.com/fmtlib/fmt/issues/3286, 649 https://github.com/fmtlib/fmt/pull/3290). Thanks @BRevzin. 650 651- Fixed issues with formatting of paths and ranges of paths 652 (https://github.com/fmtlib/fmt/issues/3319, 653 https://github.com/fmtlib/fmt/pull/3321 654 https://github.com/fmtlib/fmt/issues/3322). Thanks @phprus. 655 656- Improved handling of invalid Unicode in paths. 657 658- Enabled compile-time checks on Apple clang 14 and later 659 (https://github.com/fmtlib/fmt/pull/3331). Thanks @cloyce. 660 661- Improved compile-time checks of named arguments 662 (https://github.com/fmtlib/fmt/issues/3105, 663 https://github.com/fmtlib/fmt/pull/3214). Thanks @rbrich. 664 665- Fixed formatting when both alignment and `0` are given 666 (https://github.com/fmtlib/fmt/issues/3236, 667 https://github.com/fmtlib/fmt/pull/3248). Thanks @ShawnZhong. 668 669- Improved Unicode support in the experimental file API on Windows 670 (https://github.com/fmtlib/fmt/issues/3234, 671 https://github.com/fmtlib/fmt/pull/3293). Thanks @Fros1er. 672 673- Unified UTF transcoding 674 (https://github.com/fmtlib/fmt/pull/3416). Thanks @phprus. 675 676- Added support for UTF-8 digit separators via an experimental locale 677 facet (https://github.com/fmtlib/fmt/issues/1861). For 678 example ([godbolt](https://godbolt.org/z/f7bcznb3W)): 679 680 ```c++ 681 auto loc = std::locale( 682 std::locale(), new fmt::format_facet<std::locale>("’")); 683 auto s = fmt::format(loc, "{:L}", 1000); 684 ``` 685 686 where `’` is U+2019 used as a digit separator in the de_CH locale. 687 688- Added an overload of `formatted_size` that takes a locale 689 (https://github.com/fmtlib/fmt/issues/3084, 690 https://github.com/fmtlib/fmt/pull/3087). Thanks @gerboengels. 691 692- Removed the deprecated `FMT_DEPRECATED_OSTREAM`. 693 694- Fixed a UB when using a null `std::string_view` with 695 `fmt::to_string` or format string compilation 696 (https://github.com/fmtlib/fmt/issues/3241, 697 https://github.com/fmtlib/fmt/pull/3244). Thanks @phprus. 698 699- Added `starts_with` to the fallback `string_view` implementation 700 (https://github.com/fmtlib/fmt/pull/3080). Thanks @phprus. 701 702- Added `fmt::basic_format_string::get()` for compatibility with 703 `basic_format_string` 704 (https://github.com/fmtlib/fmt/pull/3111). Thanks @huangqinjin. 705 706- Added `println` for compatibility with C++23 707 (https://github.com/fmtlib/fmt/pull/3267). Thanks @ShawnZhong. 708 709- Renamed the `FMT_EXPORT` macro for shared library usage to 710 `FMT_LIB_EXPORT`. 711 712- Improved documentation 713 (https://github.com/fmtlib/fmt/issues/3108, 714 https://github.com/fmtlib/fmt/issues/3169, 715 https://github.com/fmtlib/fmt/pull/3243). 716 https://github.com/fmtlib/fmt/pull/3404). 717 Thanks @Cleroth and @Vertexwahn. 718 719- Improved build configuration and tests 720 (https://github.com/fmtlib/fmt/pull/3118, 721 https://github.com/fmtlib/fmt/pull/3120, 722 https://github.com/fmtlib/fmt/pull/3188, 723 https://github.com/fmtlib/fmt/issues/3189, 724 https://github.com/fmtlib/fmt/pull/3198, 725 https://github.com/fmtlib/fmt/pull/3205, 726 https://github.com/fmtlib/fmt/pull/3207, 727 https://github.com/fmtlib/fmt/pull/3210, 728 https://github.com/fmtlib/fmt/pull/3240, 729 https://github.com/fmtlib/fmt/pull/3256, 730 https://github.com/fmtlib/fmt/pull/3264, 731 https://github.com/fmtlib/fmt/issues/3299, 732 https://github.com/fmtlib/fmt/pull/3302, 733 https://github.com/fmtlib/fmt/pull/3312, 734 https://github.com/fmtlib/fmt/issues/3317, 735 https://github.com/fmtlib/fmt/pull/3328, 736 https://github.com/fmtlib/fmt/pull/3333, 737 https://github.com/fmtlib/fmt/pull/3369, 738 https://github.com/fmtlib/fmt/issues/3373, 739 https://github.com/fmtlib/fmt/pull/3395, 740 https://github.com/fmtlib/fmt/pull/3406, 741 https://github.com/fmtlib/fmt/pull/3411). 742 Thanks @dimztimz, @phprus, @DavidKorczynski, @ChrisThrasher, 743 @FrancoisCarouge, @kennyweiss, @luzpaz, @codeinred, @Mixaill, @joycebrum, 744 @kevinhwang and @Vertexwahn. 745 746- Fixed a regression in handling empty format specifiers after a colon 747 (`{:}`) (https://github.com/fmtlib/fmt/pull/3086). Thanks @oxidase. 748 749- Worked around a broken implementation of 750 `std::is_constant_evaluated` in some versions of libstdc++ on clang 751 (https://github.com/fmtlib/fmt/issues/3247, 752 https://github.com/fmtlib/fmt/pull/3281). Thanks @phprus. 753 754- Fixed formatting of volatile variables 755 (https://github.com/fmtlib/fmt/pull/3068). 756 757- Fixed various warnings and compilation issues 758 (https://github.com/fmtlib/fmt/pull/3057, 759 https://github.com/fmtlib/fmt/pull/3066, 760 https://github.com/fmtlib/fmt/pull/3072, 761 https://github.com/fmtlib/fmt/pull/3082, 762 https://github.com/fmtlib/fmt/pull/3091, 763 https://github.com/fmtlib/fmt/issues/3092, 764 https://github.com/fmtlib/fmt/pull/3093, 765 https://github.com/fmtlib/fmt/pull/3095, 766 https://github.com/fmtlib/fmt/issues/3096, 767 https://github.com/fmtlib/fmt/pull/3097, 768 https://github.com/fmtlib/fmt/issues/3128, 769 https://github.com/fmtlib/fmt/pull/3129, 770 https://github.com/fmtlib/fmt/pull/3137, 771 https://github.com/fmtlib/fmt/pull/3139, 772 https://github.com/fmtlib/fmt/issues/3140, 773 https://github.com/fmtlib/fmt/pull/3142, 774 https://github.com/fmtlib/fmt/issues/3149, 775 https://github.com/fmtlib/fmt/pull/3150, 776 https://github.com/fmtlib/fmt/issues/3154, 777 https://github.com/fmtlib/fmt/issues/3163, 778 https://github.com/fmtlib/fmt/issues/3178, 779 https://github.com/fmtlib/fmt/pull/3184, 780 https://github.com/fmtlib/fmt/pull/3196, 781 https://github.com/fmtlib/fmt/issues/3204, 782 https://github.com/fmtlib/fmt/pull/3206, 783 https://github.com/fmtlib/fmt/pull/3208, 784 https://github.com/fmtlib/fmt/issues/3213, 785 https://github.com/fmtlib/fmt/pull/3216, 786 https://github.com/fmtlib/fmt/issues/3224, 787 https://github.com/fmtlib/fmt/issues/3226, 788 https://github.com/fmtlib/fmt/issues/3228, 789 https://github.com/fmtlib/fmt/pull/3229, 790 https://github.com/fmtlib/fmt/pull/3259, 791 https://github.com/fmtlib/fmt/issues/3274, 792 https://github.com/fmtlib/fmt/issues/3287, 793 https://github.com/fmtlib/fmt/pull/3288, 794 https://github.com/fmtlib/fmt/issues/3292, 795 https://github.com/fmtlib/fmt/pull/3295, 796 https://github.com/fmtlib/fmt/pull/3296, 797 https://github.com/fmtlib/fmt/issues/3298, 798 https://github.com/fmtlib/fmt/issues/3325, 799 https://github.com/fmtlib/fmt/pull/3326, 800 https://github.com/fmtlib/fmt/issues/3334, 801 https://github.com/fmtlib/fmt/issues/3342, 802 https://github.com/fmtlib/fmt/pull/3343, 803 https://github.com/fmtlib/fmt/issues/3351, 804 https://github.com/fmtlib/fmt/pull/3352, 805 https://github.com/fmtlib/fmt/pull/3362, 806 https://github.com/fmtlib/fmt/issues/3365, 807 https://github.com/fmtlib/fmt/pull/3366, 808 https://github.com/fmtlib/fmt/pull/3374, 809 https://github.com/fmtlib/fmt/issues/3377, 810 https://github.com/fmtlib/fmt/pull/3378, 811 https://github.com/fmtlib/fmt/issues/3381, 812 https://github.com/fmtlib/fmt/pull/3398, 813 https://github.com/fmtlib/fmt/pull/3413, 814 https://github.com/fmtlib/fmt/issues/3415). 815 Thanks @phprus, @gsjaardema, @NewbieOrange, @EngineLessCC, @asmaloney, 816 @HazardyKnusperkeks, @sergiud, @Youw, @thesmurph, @czudziakm, 817 @Roman-Koshelev, @chronoxor, @ShawnZhong, @russelltg, @glebm, @tmartin-gh, 818 @Zhaojun-Liu, @louiswins and @mogemimi. 819 820# 9.1.0 - 2022-08-27 821 822- `fmt::formatted_size` now works at compile time 823 (https://github.com/fmtlib/fmt/pull/3026). For example 824 ([godbolt](https://godbolt.org/z/1MW5rMdf8)): 825 826 ```c++ 827 #include <fmt/compile.h> 828 829 int main() { 830 using namespace fmt::literals; 831 constexpr size_t n = fmt::formatted_size("{}"_cf, 42); 832 fmt::print("{}\n", n); // prints 2 833 } 834 ``` 835 836 Thanks @marksantaniello. 837 838- Fixed handling of invalid UTF-8 839 (https://github.com/fmtlib/fmt/pull/3038, 840 https://github.com/fmtlib/fmt/pull/3044, 841 https://github.com/fmtlib/fmt/pull/3056). 842 Thanks @phprus and @skeeto. 843 844- Improved Unicode support in `ostream` overloads of `print` 845 (https://github.com/fmtlib/fmt/pull/2994, 846 https://github.com/fmtlib/fmt/pull/3001, 847 https://github.com/fmtlib/fmt/pull/3025). Thanks @dimztimz. 848 849- Fixed handling of the sign specifier in localized formatting on 850 systems with 32-bit `wchar_t` 851 (https://github.com/fmtlib/fmt/issues/3041). 852 853- Added support for wide streams to `fmt::streamed` 854 (https://github.com/fmtlib/fmt/pull/2994). Thanks @phprus. 855 856- Added the `n` specifier that disables the output of delimiters when 857 formatting ranges (https://github.com/fmtlib/fmt/pull/2981, 858 https://github.com/fmtlib/fmt/pull/2983). For example 859 ([godbolt](https://godbolt.org/z/roKqGdj8c)): 860 861 ```c++ 862 #include <fmt/ranges.h> 863 #include <vector> 864 865 int main() { 866 auto v = std::vector{1, 2, 3}; 867 fmt::print("{:n}\n", v); // prints 1, 2, 3 868 } 869 ``` 870 871 Thanks @BRevzin. 872 873- Worked around problematic `std::string_view` constructors introduced 874 in C++23 (https://github.com/fmtlib/fmt/issues/3030, 875 https://github.com/fmtlib/fmt/issues/3050). Thanks @strega-nil-ms. 876 877- Improve handling (exclusion) of recursive ranges 878 (https://github.com/fmtlib/fmt/issues/2968, 879 https://github.com/fmtlib/fmt/pull/2974). Thanks @Dani-Hub. 880 881- Improved error reporting in format string compilation 882 (https://github.com/fmtlib/fmt/issues/3055). 883 884- Improved the implementation of 885 [Dragonbox](https://github.com/jk-jeon/dragonbox), the algorithm 886 used for the default floating-point formatting 887 (https://github.com/fmtlib/fmt/pull/2984). Thanks @jk-jeon. 888 889- Fixed issues with floating-point formatting on exotic platforms. 890 891- Improved the implementation of chrono formatting 892 (https://github.com/fmtlib/fmt/pull/3010). Thanks @phprus. 893 894- Improved documentation 895 (https://github.com/fmtlib/fmt/pull/2966, 896 https://github.com/fmtlib/fmt/pull/3009, 897 https://github.com/fmtlib/fmt/issues/3020, 898 https://github.com/fmtlib/fmt/pull/3037). 899 Thanks @mwinterb, @jcelerier and @remiburtin. 900 901- Improved build configuration 902 (https://github.com/fmtlib/fmt/pull/2991, 903 https://github.com/fmtlib/fmt/pull/2995, 904 https://github.com/fmtlib/fmt/issues/3004, 905 https://github.com/fmtlib/fmt/pull/3007, 906 https://github.com/fmtlib/fmt/pull/3040). 907 Thanks @dimztimz and @hwhsu1231. 908 909- Fixed various warnings and compilation issues 910 (https://github.com/fmtlib/fmt/issues/2969, 911 https://github.com/fmtlib/fmt/pull/2971, 912 https://github.com/fmtlib/fmt/issues/2975, 913 https://github.com/fmtlib/fmt/pull/2982, 914 https://github.com/fmtlib/fmt/pull/2985, 915 https://github.com/fmtlib/fmt/issues/2988, 916 https://github.com/fmtlib/fmt/issues/2989, 917 https://github.com/fmtlib/fmt/issues/3000, 918 https://github.com/fmtlib/fmt/issues/3006, 919 https://github.com/fmtlib/fmt/issues/3014, 920 https://github.com/fmtlib/fmt/issues/3015, 921 https://github.com/fmtlib/fmt/pull/3021, 922 https://github.com/fmtlib/fmt/issues/3023, 923 https://github.com/fmtlib/fmt/pull/3024, 924 https://github.com/fmtlib/fmt/pull/3029, 925 https://github.com/fmtlib/fmt/pull/3043, 926 https://github.com/fmtlib/fmt/issues/3052, 927 https://github.com/fmtlib/fmt/pull/3053, 928 https://github.com/fmtlib/fmt/pull/3054). 929 Thanks @h-friederich, @dimztimz, @olupton, @bernhardmgruber and @phprus. 930 931# 9.0.0 - 2022-07-04 932 933- Switched to the internal floating point formatter for all decimal 934 presentation formats. In particular this results in consistent 935 rounding on all platforms and removing the `s[n]printf` fallback for 936 decimal FP formatting. 937 938- Compile-time floating point formatting no longer requires the 939 header-only mode. For example 940 ([godbolt](https://godbolt.org/z/G37PTeG3b)): 941 942 ```c++ 943 #include <array> 944 #include <fmt/compile.h> 945 946 consteval auto compile_time_dtoa(double value) -> std::array<char, 10> { 947 auto result = std::array<char, 10>(); 948 fmt::format_to(result.data(), FMT_COMPILE("{}"), value); 949 return result; 950 } 951 952 constexpr auto answer = compile_time_dtoa(0.42); 953 ``` 954 955 works with the default settings. 956 957- Improved the implementation of 958 [Dragonbox](https://github.com/jk-jeon/dragonbox), the algorithm 959 used for the default floating-point formatting 960 (https://github.com/fmtlib/fmt/pull/2713, 961 https://github.com/fmtlib/fmt/pull/2750). Thanks @jk-jeon. 962 963- Made `fmt::to_string` work with `__float128`. This uses the internal 964 FP formatter and works even on system without `__float128` support 965 in `[s]printf`. 966 967- Disabled automatic `std::ostream` insertion operator (`operator<<`) 968 discovery when `fmt/ostream.h` is included to prevent ODR 969 violations. You can get the old behavior by defining 970 `FMT_DEPRECATED_OSTREAM` but this will be removed in the next major 971 release. Use `fmt::streamed` or `fmt::ostream_formatter` to enable 972 formatting via `std::ostream` instead. 973 974- Added `fmt::ostream_formatter` that can be used to write `formatter` 975 specializations that perform formatting via `std::ostream`. For 976 example ([godbolt](https://godbolt.org/z/5sEc5qMsf)): 977 978 ```c++ 979 #include <fmt/ostream.h> 980 981 struct date { 982 int year, month, day; 983 984 friend std::ostream& operator<<(std::ostream& os, const date& d) { 985 return os << d.year << '-' << d.month << '-' << d.day; 986 } 987 }; 988 989 template <> struct fmt::formatter<date> : ostream_formatter {}; 990 991 std::string s = fmt::format("The date is {}", date{2012, 12, 9}); 992 // s == "The date is 2012-12-9" 993 ``` 994 995- Added the `fmt::streamed` function that takes an object and formats 996 it via `std::ostream`. For example 997 ([godbolt](https://godbolt.org/z/5G3346G1f)): 998 999 ```c++ 1000 #include <thread> 1001 #include <fmt/ostream.h> 1002 1003 int main() { 1004 fmt::print("Current thread id: {}\n", 1005 fmt::streamed(std::this_thread::get_id())); 1006 } 1007 ``` 1008 1009 Note that `fmt/std.h` provides a `formatter` specialization for 1010 `std::thread::id` so you don\'t need to format it via 1011 `std::ostream`. 1012 1013- Deprecated implicit conversions of unscoped enums to integers for 1014 consistency with scoped enums. 1015 1016- Added an argument-dependent lookup based `format_as` extension API 1017 to simplify formatting of enums. 1018 1019- Added experimental `std::variant` formatting support 1020 (https://github.com/fmtlib/fmt/pull/2941). For example 1021 ([godbolt](https://godbolt.org/z/KG9z6cq68)): 1022 1023 ```c++ 1024 #include <variant> 1025 #include <fmt/std.h> 1026 1027 int main() { 1028 auto v = std::variant<int, std::string>(42); 1029 fmt::print("{}\n", v); 1030 } 1031 ``` 1032 1033 prints: 1034 1035 variant(42) 1036 1037 Thanks @jehelset. 1038 1039- Added experimental `std::filesystem::path` formatting support 1040 (https://github.com/fmtlib/fmt/issues/2865, 1041 https://github.com/fmtlib/fmt/pull/2902, 1042 https://github.com/fmtlib/fmt/issues/2917, 1043 https://github.com/fmtlib/fmt/pull/2918). For example 1044 ([godbolt](https://godbolt.org/z/o44dMexEb)): 1045 1046 ```c++ 1047 #include <filesystem> 1048 #include <fmt/std.h> 1049 1050 int main() { 1051 fmt::print("There is no place like {}.", std::filesystem::path("/home")); 1052 } 1053 ``` 1054 1055 prints: 1056 1057 There is no place like "/home". 1058 1059 Thanks @phprus. 1060 1061- Added a `std::thread::id` formatter to `fmt/std.h`. For example 1062 ([godbolt](https://godbolt.org/z/j1azbYf3E)): 1063 1064 ```c++ 1065 #include <thread> 1066 #include <fmt/std.h> 1067 1068 int main() { 1069 fmt::print("Current thread id: {}\n", std::this_thread::get_id()); 1070 } 1071 ``` 1072 1073- Added `fmt::styled` that applies a text style to an individual 1074 argument (https://github.com/fmtlib/fmt/pull/2793). For 1075 example ([godbolt](https://godbolt.org/z/vWGW7v5M6)): 1076 1077 ```c++ 1078 #include <fmt/chrono.h> 1079 #include <fmt/color.h> 1080 1081 int main() { 1082 auto now = std::chrono::system_clock::now(); 1083 fmt::print( 1084 "[{}] {}: {}\n", 1085 fmt::styled(now, fmt::emphasis::bold), 1086 fmt::styled("error", fg(fmt::color::red)), 1087 "something went wrong"); 1088 } 1089 ``` 1090 1091 prints 1092 1093  1094 1095 Thanks @rbrugo. 1096 1097- Made `fmt::print` overload for text styles correctly handle UTF-8 1098 (https://github.com/fmtlib/fmt/issues/2681, 1099 https://github.com/fmtlib/fmt/pull/2701). Thanks @AlexGuteniev. 1100 1101- Fixed Unicode handling when writing to an ostream. 1102 1103- Added support for nested specifiers to range formatting 1104 (https://github.com/fmtlib/fmt/pull/2673). For example 1105 ([godbolt](https://godbolt.org/z/xd3Gj38cf)): 1106 1107 ```c++ 1108 #include <vector> 1109 #include <fmt/ranges.h> 1110 1111 int main() { 1112 fmt::print("{::#x}\n", std::vector{10, 20, 30}); 1113 } 1114 ``` 1115 1116 prints `[0xa, 0x14, 0x1e]`. 1117 1118 Thanks @BRevzin. 1119 1120- Implemented escaping of wide strings in ranges 1121 (https://github.com/fmtlib/fmt/pull/2904). Thanks @phprus. 1122 1123- Added support for ranges with `begin` / `end` found via the 1124 argument-dependent lookup 1125 (https://github.com/fmtlib/fmt/pull/2807). Thanks @rbrugo. 1126 1127- Fixed formatting of certain kinds of ranges of ranges 1128 (https://github.com/fmtlib/fmt/pull/2787). Thanks @BRevzin. 1129 1130- Fixed handling of maps with element types other than `std::pair` 1131 (https://github.com/fmtlib/fmt/pull/2944). Thanks @BrukerJWD. 1132 1133- Made tuple formatter enabled only if elements are formattable 1134 (https://github.com/fmtlib/fmt/issues/2939, 1135 https://github.com/fmtlib/fmt/pull/2940). Thanks @jehelset. 1136 1137- Made `fmt::join` compatible with format string compilation 1138 (https://github.com/fmtlib/fmt/issues/2719, 1139 https://github.com/fmtlib/fmt/pull/2720). Thanks @phprus. 1140 1141- Made compile-time checks work with named arguments of custom types 1142 and `std::ostream` `print` overloads 1143 (https://github.com/fmtlib/fmt/issues/2816, 1144 https://github.com/fmtlib/fmt/issues/2817, 1145 https://github.com/fmtlib/fmt/pull/2819). Thanks @timsong-cpp. 1146 1147- Removed `make_args_checked` because it is no longer needed for 1148 compile-time checks 1149 (https://github.com/fmtlib/fmt/pull/2760). Thanks @phprus. 1150 1151- Removed the following deprecated APIs: `_format`, `arg_join`, the 1152 `format_to` overload that takes a memory buffer, `[v]fprintf` that 1153 takes an `ostream`. 1154 1155- Removed the deprecated implicit conversion of `[const] signed char*` 1156 and `[const] unsigned char*` to C strings. 1157 1158- Removed the deprecated `fmt/locale.h`. 1159 1160- Replaced the deprecated `fileno()` with `descriptor()` in 1161 `buffered_file`. 1162 1163- Moved `to_string_view` to the `detail` namespace since it\'s an 1164 implementation detail. 1165 1166- Made access mode of a created file consistent with `fopen` by 1167 setting `S_IWGRP` and `S_IWOTH` 1168 (https://github.com/fmtlib/fmt/pull/2733). Thanks @arogge. 1169 1170- Removed a redundant buffer resize when formatting to `std::ostream` 1171 (https://github.com/fmtlib/fmt/issues/2842, 1172 https://github.com/fmtlib/fmt/pull/2843). Thanks @jcelerier. 1173 1174- Made precision computation for strings consistent with width 1175 (https://github.com/fmtlib/fmt/issues/2888). 1176 1177- Fixed handling of locale separators in floating point formatting 1178 (https://github.com/fmtlib/fmt/issues/2830). 1179 1180- Made sign specifiers work with `__int128_t` 1181 (https://github.com/fmtlib/fmt/issues/2773). 1182 1183- Improved support for systems such as CHERI with extra data stored in 1184 pointers (https://github.com/fmtlib/fmt/pull/2932). 1185 Thanks @davidchisnall. 1186 1187- Improved documentation 1188 (https://github.com/fmtlib/fmt/pull/2706, 1189 https://github.com/fmtlib/fmt/pull/2712, 1190 https://github.com/fmtlib/fmt/pull/2789, 1191 https://github.com/fmtlib/fmt/pull/2803, 1192 https://github.com/fmtlib/fmt/pull/2805, 1193 https://github.com/fmtlib/fmt/pull/2815, 1194 https://github.com/fmtlib/fmt/pull/2924). 1195 Thanks @BRevzin, @Pokechu22, @setoye, @rtobar, @rbrugo, @anoonD and 1196 @leha-bot. 1197 1198- Improved build configuration 1199 (https://github.com/fmtlib/fmt/pull/2766, 1200 https://github.com/fmtlib/fmt/pull/2772, 1201 https://github.com/fmtlib/fmt/pull/2836, 1202 https://github.com/fmtlib/fmt/pull/2852, 1203 https://github.com/fmtlib/fmt/pull/2907, 1204 https://github.com/fmtlib/fmt/pull/2913, 1205 https://github.com/fmtlib/fmt/pull/2914). 1206 Thanks @kambala-decapitator, @mattiasljungstrom, @kieselnb, @nathannaveen 1207 and @Vertexwahn. 1208 1209- Fixed various warnings and compilation issues 1210 (https://github.com/fmtlib/fmt/issues/2408, 1211 https://github.com/fmtlib/fmt/issues/2507, 1212 https://github.com/fmtlib/fmt/issues/2697, 1213 https://github.com/fmtlib/fmt/issues/2715, 1214 https://github.com/fmtlib/fmt/issues/2717, 1215 https://github.com/fmtlib/fmt/pull/2722, 1216 https://github.com/fmtlib/fmt/pull/2724, 1217 https://github.com/fmtlib/fmt/pull/2725, 1218 https://github.com/fmtlib/fmt/issues/2726, 1219 https://github.com/fmtlib/fmt/pull/2728, 1220 https://github.com/fmtlib/fmt/pull/2732, 1221 https://github.com/fmtlib/fmt/issues/2738, 1222 https://github.com/fmtlib/fmt/pull/2742, 1223 https://github.com/fmtlib/fmt/issues/2744, 1224 https://github.com/fmtlib/fmt/issues/2745, 1225 https://github.com/fmtlib/fmt/issues/2746, 1226 https://github.com/fmtlib/fmt/issues/2754, 1227 https://github.com/fmtlib/fmt/pull/2755, 1228 https://github.com/fmtlib/fmt/issues/2757, 1229 https://github.com/fmtlib/fmt/pull/2758, 1230 https://github.com/fmtlib/fmt/issues/2761, 1231 https://github.com/fmtlib/fmt/pull/2762, 1232 https://github.com/fmtlib/fmt/issues/2763, 1233 https://github.com/fmtlib/fmt/pull/2765, 1234 https://github.com/fmtlib/fmt/issues/2769, 1235 https://github.com/fmtlib/fmt/pull/2770, 1236 https://github.com/fmtlib/fmt/issues/2771, 1237 https://github.com/fmtlib/fmt/issues/2777, 1238 https://github.com/fmtlib/fmt/pull/2779, 1239 https://github.com/fmtlib/fmt/pull/2782, 1240 https://github.com/fmtlib/fmt/pull/2783, 1241 https://github.com/fmtlib/fmt/issues/2794, 1242 https://github.com/fmtlib/fmt/issues/2796, 1243 https://github.com/fmtlib/fmt/pull/2797, 1244 https://github.com/fmtlib/fmt/pull/2801, 1245 https://github.com/fmtlib/fmt/pull/2802, 1246 https://github.com/fmtlib/fmt/issues/2808, 1247 https://github.com/fmtlib/fmt/issues/2818, 1248 https://github.com/fmtlib/fmt/pull/2819, 1249 https://github.com/fmtlib/fmt/issues/2829, 1250 https://github.com/fmtlib/fmt/issues/2835, 1251 https://github.com/fmtlib/fmt/issues/2848, 1252 https://github.com/fmtlib/fmt/issues/2860, 1253 https://github.com/fmtlib/fmt/pull/2861, 1254 https://github.com/fmtlib/fmt/pull/2882, 1255 https://github.com/fmtlib/fmt/issues/2886, 1256 https://github.com/fmtlib/fmt/issues/2891, 1257 https://github.com/fmtlib/fmt/pull/2892, 1258 https://github.com/fmtlib/fmt/issues/2895, 1259 https://github.com/fmtlib/fmt/issues/2896, 1260 https://github.com/fmtlib/fmt/pull/2903, 1261 https://github.com/fmtlib/fmt/issues/2906, 1262 https://github.com/fmtlib/fmt/issues/2908, 1263 https://github.com/fmtlib/fmt/pull/2909, 1264 https://github.com/fmtlib/fmt/issues/2920, 1265 https://github.com/fmtlib/fmt/pull/2922, 1266 https://github.com/fmtlib/fmt/pull/2927, 1267 https://github.com/fmtlib/fmt/pull/2929, 1268 https://github.com/fmtlib/fmt/issues/2936, 1269 https://github.com/fmtlib/fmt/pull/2937, 1270 https://github.com/fmtlib/fmt/pull/2938, 1271 https://github.com/fmtlib/fmt/pull/2951, 1272 https://github.com/fmtlib/fmt/issues/2954, 1273 https://github.com/fmtlib/fmt/pull/2957, 1274 https://github.com/fmtlib/fmt/issues/2958, 1275 https://github.com/fmtlib/fmt/pull/2960). 1276 Thanks @matrackif @Tobi823, @ivan-volnov, @VasiliPupkin256, 1277 @federico-busato, @barcharcraz, @jk-jeon, @HazardyKnusperkeks, @dalboris, 1278 @seanm, @gsjaardema, @timsong-cpp, @seanm, @frithrah, @chronoxor, @Agga, 1279 @madmaxoft, @JurajX, @phprus and @Dani-Hub. 1280 1281# 8.1.1 - 2022-01-06 1282 1283- Restored ABI compatibility with version 8.0.x 1284 (https://github.com/fmtlib/fmt/issues/2695, 1285 https://github.com/fmtlib/fmt/pull/2696). Thanks @saraedum. 1286- Fixed chrono formatting on big endian systems 1287 (https://github.com/fmtlib/fmt/issues/2698, 1288 https://github.com/fmtlib/fmt/pull/2699). 1289 Thanks @phprus and @xvitaly. 1290- Fixed a linkage error with mingw 1291 (https://github.com/fmtlib/fmt/issues/2691, 1292 https://github.com/fmtlib/fmt/pull/2692). Thanks @rbberger. 1293 1294# 8.1.0 - 2022-01-02 1295 1296- Optimized chrono formatting 1297 (https://github.com/fmtlib/fmt/pull/2500, 1298 https://github.com/fmtlib/fmt/pull/2537, 1299 https://github.com/fmtlib/fmt/issues/2541, 1300 https://github.com/fmtlib/fmt/pull/2544, 1301 https://github.com/fmtlib/fmt/pull/2550, 1302 https://github.com/fmtlib/fmt/pull/2551, 1303 https://github.com/fmtlib/fmt/pull/2576, 1304 https://github.com/fmtlib/fmt/issues/2577, 1305 https://github.com/fmtlib/fmt/pull/2586, 1306 https://github.com/fmtlib/fmt/pull/2591, 1307 https://github.com/fmtlib/fmt/pull/2594, 1308 https://github.com/fmtlib/fmt/pull/2602, 1309 https://github.com/fmtlib/fmt/pull/2617, 1310 https://github.com/fmtlib/fmt/issues/2628, 1311 https://github.com/fmtlib/fmt/pull/2633, 1312 https://github.com/fmtlib/fmt/issues/2670, 1313 https://github.com/fmtlib/fmt/pull/2671). 1314 1315 Processing of some specifiers such as `%z` and `%Y` is now up to 1316 10-20 times faster, for example on GCC 11 with libstdc++: 1317 1318 ---------------------------------------------------------------------------- 1319 Benchmark Before After 1320 ---------------------------------------------------------------------------- 1321 FMTFormatter_z 261 ns 26.3 ns 1322 FMTFormatterCompile_z 246 ns 11.6 ns 1323 FMTFormatter_Y 263 ns 26.1 ns 1324 FMTFormatterCompile_Y 244 ns 10.5 ns 1325 ---------------------------------------------------------------------------- 1326 1327 Thanks @phprus and @toughengineer. 1328 1329- Implemented subsecond formatting for chrono durations 1330 (https://github.com/fmtlib/fmt/pull/2623). For example 1331 ([godbolt](https://godbolt.org/z/es7vWTETe)): 1332 1333 ```c++ 1334 #include <fmt/chrono.h> 1335 1336 int main() { 1337 fmt::print("{:%S}", std::chrono::milliseconds(1234)); 1338 } 1339 ``` 1340 1341 prints \"01.234\". 1342 1343 Thanks @matrackif. 1344 1345- Fixed handling of precision 0 when formatting chrono durations 1346 (https://github.com/fmtlib/fmt/issues/2587, 1347 https://github.com/fmtlib/fmt/pull/2588). Thanks @lukester1975. 1348 1349- Fixed an overflow on invalid inputs in the `tm` formatter 1350 (https://github.com/fmtlib/fmt/pull/2564). Thanks @phprus. 1351 1352- Added `fmt::group_digits` that formats integers with a non-localized 1353 digit separator (comma) for groups of three digits. For example 1354 ([godbolt](https://godbolt.org/z/TxGxG9Poq)): 1355 1356 ```c++ 1357 #include <fmt/format.h> 1358 1359 int main() { 1360 fmt::print("{} dollars", fmt::group_digits(1000000)); 1361 } 1362 ``` 1363 1364 prints \"1,000,000 dollars\". 1365 1366- Added support for faint, conceal, reverse and blink text styles 1367 (https://github.com/fmtlib/fmt/pull/2394): 1368 1369 <https://user-images.githubusercontent.com/576385/147710227-c68f5317-f8fa-42c3-9123-7c4ba3c398cb.mp4> 1370 1371 Thanks @benit8 and @data-man. 1372 1373- Added experimental support for compile-time floating point 1374 formatting (https://github.com/fmtlib/fmt/pull/2426, 1375 https://github.com/fmtlib/fmt/pull/2470). It is currently 1376 limited to the header-only mode. Thanks @alexezeder. 1377 1378- Added UDL-based named argument support to compile-time format string 1379 checks (https://github.com/fmtlib/fmt/issues/2640, 1380 https://github.com/fmtlib/fmt/pull/2649). For example 1381 ([godbolt](https://godbolt.org/z/ohGbbvonv)): 1382 1383 ```c++ 1384 #include <fmt/format.h> 1385 1386 int main() { 1387 using namespace fmt::literals; 1388 fmt::print("{answer:s}", "answer"_a=42); 1389 } 1390 ``` 1391 1392 gives a compile-time error on compilers with C++20 `consteval` and 1393 non-type template parameter support (gcc 10+) because `s` is not a 1394 valid format specifier for an integer. 1395 1396 Thanks @alexezeder. 1397 1398- Implemented escaping of string range elements. For example 1399 ([godbolt](https://godbolt.org/z/rKvM1vKf3)): 1400 1401 ```c++ 1402 #include <fmt/ranges.h> 1403 #include <vector> 1404 1405 int main() { 1406 fmt::print("{}", std::vector<std::string>{"\naan"}); 1407 } 1408 ``` 1409 1410 is now printed as: 1411 1412 ["\naan"] 1413 1414 instead of: 1415 1416 [" 1417 aan"] 1418 1419- Added an experimental `?` specifier for escaping strings. 1420 (https://github.com/fmtlib/fmt/pull/2674). Thanks @BRevzin. 1421 1422- Switched to JSON-like representation of maps and sets for 1423 consistency with Python\'s `str.format`. For example 1424 ([godbolt](https://godbolt.org/z/seKjoY9W5)): 1425 1426 ```c++ 1427 #include <fmt/ranges.h> 1428 #include <map> 1429 1430 int main() { 1431 fmt::print("{}", std::map<std::string, int>{{"answer", 42}}); 1432 } 1433 ``` 1434 1435 is now printed as: 1436 1437 {"answer": 42} 1438 1439- Extended `fmt::join` to support C++20-only ranges 1440 (https://github.com/fmtlib/fmt/pull/2549). Thanks @BRevzin. 1441 1442- Optimized handling of non-const-iterable ranges and implemented 1443 initial support for non-const-formattable types. 1444 1445- Disabled implicit conversions of scoped enums to integers that was 1446 accidentally introduced in earlier versions 1447 (https://github.com/fmtlib/fmt/pull/1841). 1448 1449- Deprecated implicit conversion of `[const] signed char*` and 1450 `[const] unsigned char*` to C strings. 1451 1452- Deprecated `_format`, a legacy UDL-based format API 1453 (https://github.com/fmtlib/fmt/pull/2646). Thanks @alexezeder. 1454 1455- Marked `format`, `formatted_size` and `to_string` as `[[nodiscard]]` 1456 (https://github.com/fmtlib/fmt/pull/2612). @0x8000-0000. 1457 1458- Added missing diagnostic when trying to format function and member 1459 pointers as well as objects convertible to pointers which is 1460 explicitly disallowed 1461 (https://github.com/fmtlib/fmt/issues/2598, 1462 https://github.com/fmtlib/fmt/pull/2609, 1463 https://github.com/fmtlib/fmt/pull/2610). Thanks @AlexGuteniev. 1464 1465- Optimized writing to a contiguous buffer with `format_to_n` 1466 (https://github.com/fmtlib/fmt/pull/2489). Thanks @Roman-Koshelev. 1467 1468- Optimized writing to non-`char` buffers 1469 (https://github.com/fmtlib/fmt/pull/2477). Thanks @Roman-Koshelev. 1470 1471- Decimal point is now localized when using the `L` specifier. 1472 1473- Improved floating point formatter implementation 1474 (https://github.com/fmtlib/fmt/pull/2498, 1475 https://github.com/fmtlib/fmt/pull/2499). Thanks @Roman-Koshelev. 1476 1477- Fixed handling of very large precision in fixed format 1478 (https://github.com/fmtlib/fmt/pull/2616). 1479 1480- Made a table of cached powers used in FP formatting static 1481 (https://github.com/fmtlib/fmt/pull/2509). Thanks @jk-jeon. 1482 1483- Resolved a lookup ambiguity with C++20 format-related functions due 1484 to ADL (https://github.com/fmtlib/fmt/issues/2639, 1485 https://github.com/fmtlib/fmt/pull/2641). Thanks @mkurdej. 1486 1487- Removed unnecessary inline namespace qualification 1488 (https://github.com/fmtlib/fmt/issues/2642, 1489 https://github.com/fmtlib/fmt/pull/2643). Thanks @mkurdej. 1490 1491- Implemented argument forwarding in `format_to_n` 1492 (https://github.com/fmtlib/fmt/issues/2462, 1493 https://github.com/fmtlib/fmt/pull/2463). Thanks @owent. 1494 1495- Fixed handling of implicit conversions in `fmt::to_string` and 1496 format string compilation 1497 (https://github.com/fmtlib/fmt/issues/2565). 1498 1499- Changed the default access mode of files created by 1500 `fmt::output_file` to `-rw-r--r--` for consistency with `fopen` 1501 (https://github.com/fmtlib/fmt/issues/2530). 1502 1503- Make `fmt::ostream::flush` public 1504 (https://github.com/fmtlib/fmt/issues/2435). 1505 1506- Improved C++14/17 attribute detection 1507 (https://github.com/fmtlib/fmt/pull/2615). Thanks @AlexGuteniev. 1508 1509- Improved `consteval` detection for MSVC 1510 (https://github.com/fmtlib/fmt/pull/2559). Thanks @DanielaE. 1511 1512- Improved documentation 1513 (https://github.com/fmtlib/fmt/issues/2406, 1514 https://github.com/fmtlib/fmt/pull/2446, 1515 https://github.com/fmtlib/fmt/issues/2493, 1516 https://github.com/fmtlib/fmt/issues/2513, 1517 https://github.com/fmtlib/fmt/pull/2515, 1518 https://github.com/fmtlib/fmt/issues/2522, 1519 https://github.com/fmtlib/fmt/pull/2562, 1520 https://github.com/fmtlib/fmt/pull/2575, 1521 https://github.com/fmtlib/fmt/pull/2606, 1522 https://github.com/fmtlib/fmt/pull/2620, 1523 https://github.com/fmtlib/fmt/issues/2676). 1524 Thanks @sobolevn, @UnePierre, @zhsj, @phprus, @ericcurtin and @Lounarok. 1525 1526- Improved fuzzers and added a fuzzer for chrono timepoint formatting 1527 (https://github.com/fmtlib/fmt/pull/2461, 1528 https://github.com/fmtlib/fmt/pull/2469). @pauldreik, 1529 1530- Added the `FMT_SYSTEM_HEADERS` CMake option setting which marks 1531 {fmt}\'s headers as system. It can be used to suppress warnings 1532 (https://github.com/fmtlib/fmt/issues/2644, 1533 https://github.com/fmtlib/fmt/pull/2651). Thanks @alexezeder. 1534 1535- Added the Bazel build system support 1536 (https://github.com/fmtlib/fmt/pull/2505, 1537 https://github.com/fmtlib/fmt/pull/2516). Thanks @Vertexwahn. 1538 1539- Improved build configuration and tests 1540 (https://github.com/fmtlib/fmt/issues/2437, 1541 https://github.com/fmtlib/fmt/pull/2558, 1542 https://github.com/fmtlib/fmt/pull/2648, 1543 https://github.com/fmtlib/fmt/pull/2650, 1544 https://github.com/fmtlib/fmt/pull/2663, 1545 https://github.com/fmtlib/fmt/pull/2677). 1546 Thanks @DanielaE, @alexezeder and @phprus. 1547 1548- Fixed various warnings and compilation issues 1549 (https://github.com/fmtlib/fmt/pull/2353, 1550 https://github.com/fmtlib/fmt/pull/2356, 1551 https://github.com/fmtlib/fmt/pull/2399, 1552 https://github.com/fmtlib/fmt/issues/2408, 1553 https://github.com/fmtlib/fmt/pull/2414, 1554 https://github.com/fmtlib/fmt/pull/2427, 1555 https://github.com/fmtlib/fmt/pull/2432, 1556 https://github.com/fmtlib/fmt/pull/2442, 1557 https://github.com/fmtlib/fmt/pull/2434, 1558 https://github.com/fmtlib/fmt/issues/2439, 1559 https://github.com/fmtlib/fmt/pull/2447, 1560 https://github.com/fmtlib/fmt/pull/2450, 1561 https://github.com/fmtlib/fmt/issues/2455, 1562 https://github.com/fmtlib/fmt/issues/2465, 1563 https://github.com/fmtlib/fmt/issues/2472, 1564 https://github.com/fmtlib/fmt/issues/2474, 1565 https://github.com/fmtlib/fmt/pull/2476, 1566 https://github.com/fmtlib/fmt/issues/2478, 1567 https://github.com/fmtlib/fmt/issues/2479, 1568 https://github.com/fmtlib/fmt/issues/2481, 1569 https://github.com/fmtlib/fmt/pull/2482, 1570 https://github.com/fmtlib/fmt/pull/2483, 1571 https://github.com/fmtlib/fmt/issues/2490, 1572 https://github.com/fmtlib/fmt/pull/2491, 1573 https://github.com/fmtlib/fmt/pull/2510, 1574 https://github.com/fmtlib/fmt/pull/2518, 1575 https://github.com/fmtlib/fmt/issues/2528, 1576 https://github.com/fmtlib/fmt/pull/2529, 1577 https://github.com/fmtlib/fmt/pull/2539, 1578 https://github.com/fmtlib/fmt/issues/2540, 1579 https://github.com/fmtlib/fmt/pull/2545, 1580 https://github.com/fmtlib/fmt/pull/2555, 1581 https://github.com/fmtlib/fmt/issues/2557, 1582 https://github.com/fmtlib/fmt/issues/2570, 1583 https://github.com/fmtlib/fmt/pull/2573, 1584 https://github.com/fmtlib/fmt/pull/2582, 1585 https://github.com/fmtlib/fmt/issues/2605, 1586 https://github.com/fmtlib/fmt/pull/2611, 1587 https://github.com/fmtlib/fmt/pull/2647, 1588 https://github.com/fmtlib/fmt/issues/2627, 1589 https://github.com/fmtlib/fmt/pull/2630, 1590 https://github.com/fmtlib/fmt/issues/2635, 1591 https://github.com/fmtlib/fmt/issues/2638, 1592 https://github.com/fmtlib/fmt/issues/2653, 1593 https://github.com/fmtlib/fmt/issues/2654, 1594 https://github.com/fmtlib/fmt/issues/2661, 1595 https://github.com/fmtlib/fmt/pull/2664, 1596 https://github.com/fmtlib/fmt/pull/2684). 1597 Thanks @DanielaE, @mwinterb, @cdacamar, @TrebledJ, @bodomartin, @cquammen, 1598 @white238, @mmarkeloff, @palacaze, @jcelerier, @mborn-adi, @BrukerJWD, 1599 @spyridon97, @phprus, @oliverlee, @joshessman-llnl, @akohlmey, @timkalu, 1600 @olupton, @Acretock, @alexezeder, @andrewcorrigan, @lucpelletier and 1601 @HazardyKnusperkeks. 1602 1603# 8.0.1 - 2021-07-02 1604 1605- Fixed the version number in the inline namespace 1606 (https://github.com/fmtlib/fmt/issues/2374). 1607- Added a missing presentation type check for `std::string` 1608 (https://github.com/fmtlib/fmt/issues/2402). 1609- Fixed a linkage error when mixing code built with clang and gcc 1610 (https://github.com/fmtlib/fmt/issues/2377). 1611- Fixed documentation issues 1612 (https://github.com/fmtlib/fmt/pull/2396, 1613 https://github.com/fmtlib/fmt/issues/2403, 1614 https://github.com/fmtlib/fmt/issues/2406). Thanks @mkurdej. 1615- Removed dead code in FP formatter ( 1616 https://github.com/fmtlib/fmt/pull/2398). Thanks @javierhonduco. 1617- Fixed various warnings and compilation issues 1618 (https://github.com/fmtlib/fmt/issues/2351, 1619 https://github.com/fmtlib/fmt/issues/2359, 1620 https://github.com/fmtlib/fmt/pull/2365, 1621 https://github.com/fmtlib/fmt/issues/2368, 1622 https://github.com/fmtlib/fmt/pull/2370, 1623 https://github.com/fmtlib/fmt/pull/2376, 1624 https://github.com/fmtlib/fmt/pull/2381, 1625 https://github.com/fmtlib/fmt/pull/2382, 1626 https://github.com/fmtlib/fmt/issues/2386, 1627 https://github.com/fmtlib/fmt/pull/2389, 1628 https://github.com/fmtlib/fmt/pull/2395, 1629 https://github.com/fmtlib/fmt/pull/2397, 1630 https://github.com/fmtlib/fmt/issues/2400, 1631 https://github.com/fmtlib/fmt/issues/2401, 1632 https://github.com/fmtlib/fmt/pull/2407). 1633 Thanks @zx2c4, @AidanSun05, @mattiasljungstrom, @joemmett, @erengy, 1634 @patlkli, @gsjaardema and @phprus. 1635 1636# 8.0.0 - 2021-06-21 1637 1638- Enabled compile-time format string checks by default. For example 1639 ([godbolt](https://godbolt.org/z/sMxcohGjz)): 1640 1641 ```c++ 1642 #include <fmt/core.h> 1643 1644 int main() { 1645 fmt::print("{:d}", "I am not a number"); 1646 } 1647 ``` 1648 1649 gives a compile-time error on compilers with C++20 `consteval` 1650 support (gcc 10+, clang 11+) because `d` is not a valid format 1651 specifier for a string. 1652 1653 To pass a runtime string wrap it in `fmt::runtime`: 1654 1655 ```c++ 1656 fmt::print(fmt::runtime("{:d}"), "I am not a number"); 1657 ``` 1658 1659- Added compile-time formatting 1660 (https://github.com/fmtlib/fmt/pull/2019, 1661 https://github.com/fmtlib/fmt/pull/2044, 1662 https://github.com/fmtlib/fmt/pull/2056, 1663 https://github.com/fmtlib/fmt/pull/2072, 1664 https://github.com/fmtlib/fmt/pull/2075, 1665 https://github.com/fmtlib/fmt/issues/2078, 1666 https://github.com/fmtlib/fmt/pull/2129, 1667 https://github.com/fmtlib/fmt/pull/2326). For example 1668 ([godbolt](https://godbolt.org/z/Mxx9d89jM)): 1669 1670 ```c++ 1671 #include <fmt/compile.h> 1672 1673 consteval auto compile_time_itoa(int value) -> std::array<char, 10> { 1674 auto result = std::array<char, 10>(); 1675 fmt::format_to(result.data(), FMT_COMPILE("{}"), value); 1676 return result; 1677 } 1678 1679 constexpr auto answer = compile_time_itoa(42); 1680 ``` 1681 1682 Most of the formatting functionality is available at compile time 1683 with a notable exception of floating-point numbers and pointers. 1684 Thanks @alexezeder. 1685 1686- Optimized handling of format specifiers during format string 1687 compilation. For example, hexadecimal formatting (`"{:x}"`) is now 1688 3-7x faster than before when using `format_to` with format string 1689 compilation and a stack-allocated buffer 1690 (https://github.com/fmtlib/fmt/issues/1944). 1691 1692 Before (7.1.3): 1693 1694 ---------------------------------------------------------------------------- 1695 Benchmark Time CPU Iterations 1696 ---------------------------------------------------------------------------- 1697 FMTCompileOld/0 15.5 ns 15.5 ns 43302898 1698 FMTCompileOld/42 16.6 ns 16.6 ns 43278267 1699 FMTCompileOld/273123 18.7 ns 18.6 ns 37035861 1700 FMTCompileOld/9223372036854775807 19.4 ns 19.4 ns 35243000 1701 ---------------------------------------------------------------------------- 1702 1703 After (8.x): 1704 1705 ---------------------------------------------------------------------------- 1706 Benchmark Time CPU Iterations 1707 ---------------------------------------------------------------------------- 1708 FMTCompileNew/0 1.99 ns 1.99 ns 360523686 1709 FMTCompileNew/42 2.33 ns 2.33 ns 279865664 1710 FMTCompileNew/273123 3.72 ns 3.71 ns 190230315 1711 FMTCompileNew/9223372036854775807 5.28 ns 5.26 ns 130711631 1712 ---------------------------------------------------------------------------- 1713 1714 It is even faster than `std::to_chars` from libc++ compiled with 1715 clang on macOS: 1716 1717 ---------------------------------------------------------------------------- 1718 Benchmark Time CPU Iterations 1719 ---------------------------------------------------------------------------- 1720 ToChars/0 4.42 ns 4.41 ns 160196630 1721 ToChars/42 5.00 ns 4.98 ns 140735201 1722 ToChars/273123 7.26 ns 7.24 ns 95784130 1723 ToChars/9223372036854775807 8.77 ns 8.75 ns 75872534 1724 ---------------------------------------------------------------------------- 1725 1726 In other cases, especially involving `std::string` construction, the 1727 speed up is usually lower because handling format specifiers takes a 1728 smaller fraction of the total time. 1729 1730- Added the `_cf` user-defined literal to represent a compiled format 1731 string. It can be used instead of the `FMT_COMPILE` macro 1732 (https://github.com/fmtlib/fmt/pull/2043, 1733 https://github.com/fmtlib/fmt/pull/2242): 1734 1735 ```c++ 1736 #include <fmt/compile.h> 1737 1738 using namespace fmt::literals; 1739 auto s = fmt::format(FMT_COMPILE("{}"), 42); // not modern 1740 auto s = fmt::format("{}"_cf, 42); // modern as hell 1741 ``` 1742 1743 It requires compiler support for class types in non-type template 1744 parameters (a C++20 feature) which is available in GCC 9.3+. 1745 Thanks @alexezeder. 1746 1747- Format string compilation now requires `format` functions of 1748 `formatter` specializations for user-defined types to be `const`: 1749 1750 ```c++ 1751 template <> struct fmt::formatter<my_type>: formatter<string_view> { 1752 template <typename FormatContext> 1753 auto format(my_type obj, FormatContext& ctx) const { // Note const here. 1754 // ... 1755 } 1756 }; 1757 ``` 1758 1759- Added UDL-based named argument support to format string compilation 1760 (https://github.com/fmtlib/fmt/pull/2243, 1761 https://github.com/fmtlib/fmt/pull/2281). For example: 1762 1763 ```c++ 1764 #include <fmt/compile.h> 1765 1766 using namespace fmt::literals; 1767 auto s = fmt::format(FMT_COMPILE("{answer}"), "answer"_a = 42); 1768 ``` 1769 1770 Here the argument named \"answer\" is resolved at compile time with 1771 no runtime overhead. Thanks @alexezeder. 1772 1773- Added format string compilation support to `fmt::print` 1774 (https://github.com/fmtlib/fmt/issues/2280, 1775 https://github.com/fmtlib/fmt/pull/2304). Thanks @alexezeder. 1776 1777- Added initial support for compiling {fmt} as a C++20 module 1778 (https://github.com/fmtlib/fmt/pull/2235, 1779 https://github.com/fmtlib/fmt/pull/2240, 1780 https://github.com/fmtlib/fmt/pull/2260, 1781 https://github.com/fmtlib/fmt/pull/2282, 1782 https://github.com/fmtlib/fmt/pull/2283, 1783 https://github.com/fmtlib/fmt/pull/2288, 1784 https://github.com/fmtlib/fmt/pull/2298, 1785 https://github.com/fmtlib/fmt/pull/2306, 1786 https://github.com/fmtlib/fmt/pull/2307, 1787 https://github.com/fmtlib/fmt/pull/2309, 1788 https://github.com/fmtlib/fmt/pull/2318, 1789 https://github.com/fmtlib/fmt/pull/2324, 1790 https://github.com/fmtlib/fmt/pull/2332, 1791 https://github.com/fmtlib/fmt/pull/2340). Thanks @DanielaE. 1792 1793- Made symbols private by default reducing shared library size 1794 (https://github.com/fmtlib/fmt/pull/2301). For example 1795 there was a \~15% reported reduction on one platform. Thanks @sergiud. 1796 1797- Optimized includes making the result of preprocessing `fmt/format.h` 1798 \~20% smaller with libstdc++/C++20 and slightly improving build 1799 times (https://github.com/fmtlib/fmt/issues/1998). 1800 1801- Added support of ranges with non-const `begin` / `end` 1802 (https://github.com/fmtlib/fmt/pull/1953). Thanks @kitegi. 1803 1804- Added support of `std::byte` and other formattable types to 1805 `fmt::join` (https://github.com/fmtlib/fmt/issues/1981, 1806 https://github.com/fmtlib/fmt/issues/2040, 1807 https://github.com/fmtlib/fmt/pull/2050, 1808 https://github.com/fmtlib/fmt/issues/2262). For example: 1809 1810 ```c++ 1811 #include <fmt/format.h> 1812 #include <cstddef> 1813 #include <vector> 1814 1815 int main() { 1816 auto bytes = std::vector{std::byte(4), std::byte(2)}; 1817 fmt::print("{}", fmt::join(bytes, "")); 1818 } 1819 ``` 1820 1821 prints \"42\". 1822 1823 Thanks @kamibo. 1824 1825- Implemented the default format for `std::chrono::system_clock` 1826 (https://github.com/fmtlib/fmt/issues/2319, 1827 https://github.com/fmtlib/fmt/pull/2345). For example: 1828 1829 ```c++ 1830 #include <fmt/chrono.h> 1831 1832 int main() { 1833 fmt::print("{}", std::chrono::system_clock::now()); 1834 } 1835 ``` 1836 1837 prints \"2021-06-18 15:22:00\" (the output depends on the current 1838 date and time). Thanks @sunmy2019. 1839 1840- Made more chrono specifiers locale independent by default. Use the 1841 `'L'` specifier to get localized formatting. For example: 1842 1843 ```c++ 1844 #include <fmt/chrono.h> 1845 1846 int main() { 1847 std::locale::global(std::locale("ru_RU.UTF-8")); 1848 auto monday = std::chrono::weekday(1); 1849 fmt::print("{}\n", monday); // prints "Mon" 1850 fmt::print("{:L}\n", monday); // prints "пн" 1851 } 1852 ``` 1853 1854- Improved locale handling in chrono formatting 1855 (https://github.com/fmtlib/fmt/issues/2337, 1856 https://github.com/fmtlib/fmt/pull/2349, 1857 https://github.com/fmtlib/fmt/pull/2350). Thanks @phprus. 1858 1859- Deprecated `fmt/locale.h` moving the formatting functions that take 1860 a locale to `fmt/format.h` (`char`) and `fmt/xchar` (other 1861 overloads). This doesn\'t introduce a dependency on `<locale>` so 1862 there is virtually no compile time effect. 1863 1864- Deprecated an undocumented `format_to` overload that takes 1865 `basic_memory_buffer`. 1866 1867- Made parameter order in `vformat_to` consistent with `format_to` 1868 (https://github.com/fmtlib/fmt/issues/2327). 1869 1870- Added support for time points with arbitrary durations 1871 (https://github.com/fmtlib/fmt/issues/2208). For example: 1872 1873 ```c++ 1874 #include <fmt/chrono.h> 1875 1876 int main() { 1877 using tp = std::chrono::time_point< 1878 std::chrono::system_clock, std::chrono::seconds>; 1879 fmt::print("{:%S}", tp(std::chrono::seconds(42))); 1880 } 1881 ``` 1882 1883 prints \"42\". 1884 1885- Formatting floating-point numbers no longer produces trailing zeros 1886 by default for consistency with `std::format`. For example: 1887 1888 ```c++ 1889 #include <fmt/core.h> 1890 1891 int main() { 1892 fmt::print("{0:.3}", 1.1); 1893 } 1894 ``` 1895 1896 prints \"1.1\". Use the `'#'` specifier to keep trailing zeros. 1897 1898- Dropped a limit on the number of elements in a range and replaced 1899 `{}` with `[]` as range delimiters for consistency with Python\'s 1900 `str.format`. 1901 1902- The `'L'` specifier for locale-specific numeric formatting can now 1903 be combined with presentation specifiers as in `std::format`. For 1904 example: 1905 1906 ```c++ 1907 #include <fmt/core.h> 1908 #include <locale> 1909 1910 int main() { 1911 std::locale::global(std::locale("fr_FR.UTF-8")); 1912 fmt::print("{0:.2Lf}", 0.42); 1913 } 1914 ``` 1915 1916 prints \"0,42\". The deprecated `'n'` specifier has been removed. 1917 1918- Made the `0` specifier ignored for infinity and NaN 1919 (https://github.com/fmtlib/fmt/issues/2305, 1920 https://github.com/fmtlib/fmt/pull/2310). Thanks @Liedtke. 1921 1922- Made the hexfloat formatting use the right alignment by default 1923 (https://github.com/fmtlib/fmt/issues/2308, 1924 https://github.com/fmtlib/fmt/pull/2317). Thanks @Liedtke. 1925 1926- Removed the deprecated numeric alignment (`'='`). Use the `'0'` 1927 specifier instead. 1928 1929- Removed the deprecated `fmt/posix.h` header that has been replaced 1930 with `fmt/os.h`. 1931 1932- Removed the deprecated `format_to_n_context`, `format_to_n_args` and 1933 `make_format_to_n_args`. They have been replaced with 1934 `format_context`, `` format_args` and ``make_format_args\`\` 1935 respectively. 1936 1937- Moved `wchar_t`-specific functions and types to `fmt/xchar.h`. You 1938 can define `FMT_DEPRECATED_INCLUDE_XCHAR` to automatically include 1939 `fmt/xchar.h` from `fmt/format.h` but this will be disabled in the 1940 next major release. 1941 1942- Fixed handling of the `'+'` specifier in localized formatting 1943 (https://github.com/fmtlib/fmt/issues/2133). 1944 1945- Added support for the `'s'` format specifier that gives textual 1946 representation of `bool` 1947 (https://github.com/fmtlib/fmt/issues/2094, 1948 https://github.com/fmtlib/fmt/pull/2109). For example: 1949 1950 ```c++ 1951 #include <fmt/core.h> 1952 1953 int main() { 1954 fmt::print("{:s}", true); 1955 } 1956 ``` 1957 1958 prints \"true\". Thanks @powercoderlol. 1959 1960- Made `fmt::ptr` work with function pointers 1961 (https://github.com/fmtlib/fmt/pull/2131). For example: 1962 1963 ```c++ 1964 #include <fmt/format.h> 1965 1966 int main() { 1967 fmt::print("My main: {}\n", fmt::ptr(main)); 1968 } 1969 ``` 1970 1971 Thanks @mikecrowe. 1972 1973- The undocumented support for specializing `formatter` for pointer 1974 types has been removed. 1975 1976- Fixed `fmt::formatted_size` with format string compilation 1977 (https://github.com/fmtlib/fmt/pull/2141, 1978 https://github.com/fmtlib/fmt/pull/2161). Thanks @alexezeder. 1979 1980- Fixed handling of empty format strings during format string 1981 compilation (https://github.com/fmtlib/fmt/issues/2042): 1982 1983 ```c++ 1984 auto s = fmt::format(FMT_COMPILE("")); 1985 ``` 1986 1987 Thanks @alexezeder. 1988 1989- Fixed handling of enums in `fmt::to_string` 1990 (https://github.com/fmtlib/fmt/issues/2036). 1991 1992- Improved width computation 1993 (https://github.com/fmtlib/fmt/issues/2033, 1994 https://github.com/fmtlib/fmt/issues/2091). For example: 1995 1996 ```c++ 1997 #include <fmt/core.h> 1998 1999 int main() { 2000 fmt::print("{:-<10}{}\n", "你好", "世界"); 2001 fmt::print("{:-<10}{}\n", "hello", "world"); 2002 } 2003 ``` 2004 2005 prints 2006 2007  2008 2009 on a modern terminal. 2010 2011- The experimental fast output stream (`fmt::ostream`) is now 2012 truncated by default for consistency with `fopen` 2013 (https://github.com/fmtlib/fmt/issues/2018). For example: 2014 2015 ```c++ 2016 #include <fmt/os.h> 2017 2018 int main() { 2019 fmt::ostream out1 = fmt::output_file("guide"); 2020 out1.print("Zaphod"); 2021 out1.close(); 2022 fmt::ostream out2 = fmt::output_file("guide"); 2023 out2.print("Ford"); 2024 } 2025 ``` 2026 2027 writes \"Ford\" to the file \"guide\". To preserve the old file 2028 content if any pass `fmt::file::WRONLY | fmt::file::CREATE` flags to 2029 `fmt::output_file`. 2030 2031- Fixed moving of `fmt::ostream` that holds buffered data 2032 (https://github.com/fmtlib/fmt/issues/2197, 2033 https://github.com/fmtlib/fmt/pull/2198). Thanks @vtta. 2034 2035- Replaced the `fmt::system_error` exception with a function of the 2036 same name that constructs `std::system_error` 2037 (https://github.com/fmtlib/fmt/issues/2266). 2038 2039- Replaced the `fmt::windows_error` exception with a function of the 2040 same name that constructs `std::system_error` with the category 2041 returned by `fmt::system_category()` 2042 (https://github.com/fmtlib/fmt/issues/2274, 2043 https://github.com/fmtlib/fmt/pull/2275). The latter is 2044 similar to `std::sytem_category` but correctly handles UTF-8. 2045 Thanks @phprus. 2046 2047- Replaced `fmt::error_code` with `std::error_code` and made it 2048 formattable (https://github.com/fmtlib/fmt/issues/2269, 2049 https://github.com/fmtlib/fmt/pull/2270, 2050 https://github.com/fmtlib/fmt/pull/2273). Thanks @phprus. 2051 2052- Added speech synthesis support 2053 (https://github.com/fmtlib/fmt/pull/2206). 2054 2055- Made `format_to` work with a memory buffer that has a custom 2056 allocator (https://github.com/fmtlib/fmt/pull/2300). 2057 Thanks @voxmea. 2058 2059- Added `Allocator::max_size` support to `basic_memory_buffer`. 2060 (https://github.com/fmtlib/fmt/pull/1960). Thanks @phprus. 2061 2062- Added wide string support to `fmt::join` 2063 (https://github.com/fmtlib/fmt/pull/2236). Thanks @crbrz. 2064 2065- Made iterators passed to `formatter` specializations via a format 2066 context satisfy C++20 `std::output_iterator` requirements 2067 (https://github.com/fmtlib/fmt/issues/2156, 2068 https://github.com/fmtlib/fmt/pull/2158, 2069 https://github.com/fmtlib/fmt/issues/2195, 2070 https://github.com/fmtlib/fmt/pull/2204). Thanks @randomnetcat. 2071 2072- Optimized the `printf` implementation 2073 (https://github.com/fmtlib/fmt/pull/1982, 2074 https://github.com/fmtlib/fmt/pull/1984, 2075 https://github.com/fmtlib/fmt/pull/2016, 2076 https://github.com/fmtlib/fmt/pull/2164). 2077 Thanks @rimathia and @moiwi. 2078 2079- Improved detection of `constexpr` `char_traits` 2080 (https://github.com/fmtlib/fmt/pull/2246, 2081 https://github.com/fmtlib/fmt/pull/2257). Thanks @phprus. 2082 2083- Fixed writing to `stdout` when it is redirected to `NUL` on Windows 2084 (https://github.com/fmtlib/fmt/issues/2080). 2085 2086- Fixed exception propagation from iterators 2087 (https://github.com/fmtlib/fmt/issues/2097). 2088 2089- Improved `strftime` error handling 2090 (https://github.com/fmtlib/fmt/issues/2238, 2091 https://github.com/fmtlib/fmt/pull/2244). Thanks @yumeyao. 2092 2093- Stopped using deprecated GCC UDL template extension. 2094 2095- Added `fmt/args.h` to the install target 2096 (https://github.com/fmtlib/fmt/issues/2096). 2097 2098- Error messages are now passed to assert when exceptions are disabled 2099 (https://github.com/fmtlib/fmt/pull/2145). Thanks @NobodyXu. 2100 2101- Added the `FMT_MASTER_PROJECT` CMake option to control build and 2102 install targets when {fmt} is included via `add_subdirectory` 2103 (https://github.com/fmtlib/fmt/issues/2098, 2104 https://github.com/fmtlib/fmt/pull/2100). 2105 Thanks @randomizedthinking. 2106 2107- Improved build configuration 2108 (https://github.com/fmtlib/fmt/pull/2026, 2109 https://github.com/fmtlib/fmt/pull/2122). 2110 Thanks @luncliff and @ibaned. 2111 2112- Fixed various warnings and compilation issues 2113 (https://github.com/fmtlib/fmt/issues/1947, 2114 https://github.com/fmtlib/fmt/pull/1959, 2115 https://github.com/fmtlib/fmt/pull/1963, 2116 https://github.com/fmtlib/fmt/pull/1965, 2117 https://github.com/fmtlib/fmt/issues/1966, 2118 https://github.com/fmtlib/fmt/pull/1974, 2119 https://github.com/fmtlib/fmt/pull/1975, 2120 https://github.com/fmtlib/fmt/pull/1990, 2121 https://github.com/fmtlib/fmt/issues/2000, 2122 https://github.com/fmtlib/fmt/pull/2001, 2123 https://github.com/fmtlib/fmt/issues/2002, 2124 https://github.com/fmtlib/fmt/issues/2004, 2125 https://github.com/fmtlib/fmt/pull/2006, 2126 https://github.com/fmtlib/fmt/pull/2009, 2127 https://github.com/fmtlib/fmt/pull/2010, 2128 https://github.com/fmtlib/fmt/issues/2038, 2129 https://github.com/fmtlib/fmt/issues/2039, 2130 https://github.com/fmtlib/fmt/issues/2047, 2131 https://github.com/fmtlib/fmt/pull/2053, 2132 https://github.com/fmtlib/fmt/issues/2059, 2133 https://github.com/fmtlib/fmt/pull/2065, 2134 https://github.com/fmtlib/fmt/pull/2067, 2135 https://github.com/fmtlib/fmt/pull/2068, 2136 https://github.com/fmtlib/fmt/pull/2073, 2137 https://github.com/fmtlib/fmt/issues/2103, 2138 https://github.com/fmtlib/fmt/issues/2105, 2139 https://github.com/fmtlib/fmt/pull/2106, 2140 https://github.com/fmtlib/fmt/pull/2107, 2141 https://github.com/fmtlib/fmt/issues/2116, 2142 https://github.com/fmtlib/fmt/pull/2117, 2143 https://github.com/fmtlib/fmt/issues/2118, 2144 https://github.com/fmtlib/fmt/pull/2119, 2145 https://github.com/fmtlib/fmt/issues/2127, 2146 https://github.com/fmtlib/fmt/pull/2128, 2147 https://github.com/fmtlib/fmt/issues/2140, 2148 https://github.com/fmtlib/fmt/issues/2142, 2149 https://github.com/fmtlib/fmt/pull/2143, 2150 https://github.com/fmtlib/fmt/pull/2144, 2151 https://github.com/fmtlib/fmt/issues/2147, 2152 https://github.com/fmtlib/fmt/issues/2148, 2153 https://github.com/fmtlib/fmt/issues/2149, 2154 https://github.com/fmtlib/fmt/pull/2152, 2155 https://github.com/fmtlib/fmt/pull/2160, 2156 https://github.com/fmtlib/fmt/issues/2170, 2157 https://github.com/fmtlib/fmt/issues/2175, 2158 https://github.com/fmtlib/fmt/issues/2176, 2159 https://github.com/fmtlib/fmt/pull/2177, 2160 https://github.com/fmtlib/fmt/issues/2178, 2161 https://github.com/fmtlib/fmt/pull/2179, 2162 https://github.com/fmtlib/fmt/issues/2180, 2163 https://github.com/fmtlib/fmt/issues/2181, 2164 https://github.com/fmtlib/fmt/pull/2183, 2165 https://github.com/fmtlib/fmt/issues/2184, 2166 https://github.com/fmtlib/fmt/issues/2185, 2167 https://github.com/fmtlib/fmt/pull/2186, 2168 https://github.com/fmtlib/fmt/pull/2187, 2169 https://github.com/fmtlib/fmt/pull/2190, 2170 https://github.com/fmtlib/fmt/pull/2192, 2171 https://github.com/fmtlib/fmt/pull/2194, 2172 https://github.com/fmtlib/fmt/pull/2205, 2173 https://github.com/fmtlib/fmt/issues/2210, 2174 https://github.com/fmtlib/fmt/pull/2211, 2175 https://github.com/fmtlib/fmt/pull/2215, 2176 https://github.com/fmtlib/fmt/pull/2216, 2177 https://github.com/fmtlib/fmt/pull/2218, 2178 https://github.com/fmtlib/fmt/pull/2220, 2179 https://github.com/fmtlib/fmt/issues/2228, 2180 https://github.com/fmtlib/fmt/pull/2229, 2181 https://github.com/fmtlib/fmt/pull/2230, 2182 https://github.com/fmtlib/fmt/issues/2233, 2183 https://github.com/fmtlib/fmt/pull/2239, 2184 https://github.com/fmtlib/fmt/issues/2248, 2185 https://github.com/fmtlib/fmt/issues/2252, 2186 https://github.com/fmtlib/fmt/pull/2253, 2187 https://github.com/fmtlib/fmt/pull/2255, 2188 https://github.com/fmtlib/fmt/issues/2261, 2189 https://github.com/fmtlib/fmt/issues/2278, 2190 https://github.com/fmtlib/fmt/issues/2284, 2191 https://github.com/fmtlib/fmt/pull/2287, 2192 https://github.com/fmtlib/fmt/pull/2289, 2193 https://github.com/fmtlib/fmt/pull/2290, 2194 https://github.com/fmtlib/fmt/pull/2293, 2195 https://github.com/fmtlib/fmt/issues/2295, 2196 https://github.com/fmtlib/fmt/pull/2296, 2197 https://github.com/fmtlib/fmt/pull/2297, 2198 https://github.com/fmtlib/fmt/issues/2311, 2199 https://github.com/fmtlib/fmt/pull/2313, 2200 https://github.com/fmtlib/fmt/pull/2315, 2201 https://github.com/fmtlib/fmt/issues/2320, 2202 https://github.com/fmtlib/fmt/pull/2321, 2203 https://github.com/fmtlib/fmt/pull/2323, 2204 https://github.com/fmtlib/fmt/issues/2328, 2205 https://github.com/fmtlib/fmt/pull/2329, 2206 https://github.com/fmtlib/fmt/pull/2333, 2207 https://github.com/fmtlib/fmt/pull/2338, 2208 https://github.com/fmtlib/fmt/pull/2341). 2209 Thanks @darklukee, @fagg, @killerbot242, @jgopel, @yeswalrus, @Finkman, 2210 @HazardyKnusperkeks, @dkavolis, @concatime, @chronoxor, @summivox, @yNeo, 2211 @Apache-HB, @alexezeder, @toojays, @Brainy0207, @vadz, @imsherlock, @phprus, 2212 @white238, @yafshar, @BillyDonahue, @jstaahl, @denchat, @DanielaE, 2213 @ilyakurdyukov, @ilmai, @JessyDL, @sergiud, @mwinterb, @sven-herrmann, 2214 @jmelas, @twoixter, @crbrz and @upsj. 2215 2216- Improved documentation 2217 (https://github.com/fmtlib/fmt/issues/1986, 2218 https://github.com/fmtlib/fmt/pull/2051, 2219 https://github.com/fmtlib/fmt/issues/2057, 2220 https://github.com/fmtlib/fmt/pull/2081, 2221 https://github.com/fmtlib/fmt/issues/2084, 2222 https://github.com/fmtlib/fmt/pull/2312). 2223 Thanks @imba-tjd, @0x416c69 and @mordante. 2224 2225- Continuous integration and test improvements 2226 (https://github.com/fmtlib/fmt/issues/1969, 2227 https://github.com/fmtlib/fmt/pull/1991, 2228 https://github.com/fmtlib/fmt/pull/2020, 2229 https://github.com/fmtlib/fmt/pull/2110, 2230 https://github.com/fmtlib/fmt/pull/2114, 2231 https://github.com/fmtlib/fmt/issues/2196, 2232 https://github.com/fmtlib/fmt/pull/2217, 2233 https://github.com/fmtlib/fmt/pull/2247, 2234 https://github.com/fmtlib/fmt/pull/2256, 2235 https://github.com/fmtlib/fmt/pull/2336, 2236 https://github.com/fmtlib/fmt/pull/2346). 2237 Thanks @jgopel, @alexezeder and @DanielaE. 2238 2239# 7.1.3 - 2020-11-24 2240 2241- Fixed handling of buffer boundaries in `format_to_n` 2242 (https://github.com/fmtlib/fmt/issues/1996, 2243 https://github.com/fmtlib/fmt/issues/2029). 2244- Fixed linkage errors when linking with a shared library 2245 (https://github.com/fmtlib/fmt/issues/2011). 2246- Reintroduced ostream support to range formatters 2247 (https://github.com/fmtlib/fmt/issues/2014). 2248- Worked around an issue with mixing std versions in gcc 2249 (https://github.com/fmtlib/fmt/issues/2017). 2250 2251# 7.1.2 - 2020-11-04 2252 2253- Fixed floating point formatting with large precision 2254 (https://github.com/fmtlib/fmt/issues/1976). 2255 2256# 7.1.1 - 2020-11-01 2257 2258- Fixed ABI compatibility with 7.0.x 2259 (https://github.com/fmtlib/fmt/issues/1961). 2260- Added the `FMT_ARM_ABI_COMPATIBILITY` macro to work around ABI 2261 incompatibility between GCC and Clang on ARM 2262 (https://github.com/fmtlib/fmt/issues/1919). 2263- Worked around a SFINAE bug in GCC 8 2264 (https://github.com/fmtlib/fmt/issues/1957). 2265- Fixed linkage errors when building with GCC\'s LTO 2266 (https://github.com/fmtlib/fmt/issues/1955). 2267- Fixed a compilation error when building without `__builtin_clz` or 2268 equivalent (https://github.com/fmtlib/fmt/pull/1968). 2269 Thanks @tohammer. 2270- Fixed a sign conversion warning 2271 (https://github.com/fmtlib/fmt/pull/1964). Thanks @OptoCloud. 2272 2273# 7.1.0 - 2020-10-25 2274 2275- Switched from 2276 [Grisu3](https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf) 2277 to [Dragonbox](https://github.com/jk-jeon/dragonbox) for the default 2278 floating-point formatting which gives the shortest decimal 2279 representation with round-trip guarantee and correct rounding 2280 (https://github.com/fmtlib/fmt/pull/1882, 2281 https://github.com/fmtlib/fmt/pull/1887, 2282 https://github.com/fmtlib/fmt/pull/1894). This makes {fmt} 2283 up to 20-30x faster than common implementations of 2284 `std::ostringstream` and `sprintf` on 2285 [dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark) and 2286 faster than double-conversion and Ryū: 2287 2288  2289 2290 It is possible to get even better performance at the cost of larger 2291 binary size by compiling with the `FMT_USE_FULL_CACHE_DRAGONBOX` 2292 macro set to 1. 2293 2294 Thanks @jk-jeon. 2295 2296- Added an experimental unsynchronized file output API which, together 2297 with [format string 2298 compilation](https://fmt.dev/latest/api.html#compile-api), can give 2299 [5-9 times speed up compared to 2300 fprintf](https://www.zverovich.net/2020/08/04/optimal-file-buffer-size.html) 2301 on common platforms ([godbolt](https://godbolt.org/z/nsTcG8)): 2302 2303 ```c++ 2304 #include <fmt/os.h> 2305 2306 int main() { 2307 auto f = fmt::output_file("guide"); 2308 f.print("The answer is {}.", 42); 2309 } 2310 ``` 2311 2312- Added a formatter for `std::chrono::time_point<system_clock>` 2313 (https://github.com/fmtlib/fmt/issues/1819, 2314 https://github.com/fmtlib/fmt/pull/1837). For example 2315 ([godbolt](https://godbolt.org/z/c4M6fh)): 2316 2317 ```c++ 2318 #include <fmt/chrono.h> 2319 2320 int main() { 2321 auto now = std::chrono::system_clock::now(); 2322 fmt::print("The time is {:%H:%M:%S}.\n", now); 2323 } 2324 ``` 2325 2326 Thanks @adamburgess. 2327 2328- Added support for ranges with non-const `begin`/`end` to `fmt::join` 2329 (https://github.com/fmtlib/fmt/issues/1784, 2330 https://github.com/fmtlib/fmt/pull/1786). For example 2331 ([godbolt](https://godbolt.org/z/jP63Tv)): 2332 2333 ```c++ 2334 #include <fmt/ranges.h> 2335 #include <range/v3/view/filter.hpp> 2336 2337 int main() { 2338 using std::literals::string_literals::operator""s; 2339 auto strs = std::array{"a"s, "bb"s, "ccc"s}; 2340 auto range = strs | ranges::views::filter( 2341 [] (const std::string &x) { return x.size() != 2; } 2342 ); 2343 fmt::print("{}\n", fmt::join(range, "")); 2344 } 2345 ``` 2346 2347 prints \"accc\". 2348 2349 Thanks @tonyelewis. 2350 2351- Added a `memory_buffer::append` overload that takes a range 2352 (https://github.com/fmtlib/fmt/pull/1806). Thanks @BRevzin. 2353 2354- Improved handling of single code units in `FMT_COMPILE`. For 2355 example: 2356 2357 ```c++ 2358 #include <fmt/compile.h> 2359 2360 char* f(char* buf) { 2361 return fmt::format_to(buf, FMT_COMPILE("x{}"), 42); 2362 } 2363 ``` 2364 2365 compiles to just ([godbolt](https://godbolt.org/z/5vncz3)): 2366 2367 ```asm 2368 _Z1fPc: 2369 movb $120, (%rdi) 2370 xorl %edx, %edx 2371 cmpl $42, _ZN3fmt2v76detail10basic_dataIvE23zero_or_powers_of_10_32E+8(%rip) 2372 movl $3, %eax 2373 seta %dl 2374 subl %edx, %eax 2375 movzwl _ZN3fmt2v76detail10basic_dataIvE6digitsE+84(%rip), %edx 2376 cltq 2377 addq %rdi, %rax 2378 movw %dx, -2(%rax) 2379 ret 2380 ``` 2381 2382 Here a single `mov` instruction writes `'x'` (`$120`) to the output 2383 buffer. 2384 2385- Added dynamic width support to format string compilation 2386 (https://github.com/fmtlib/fmt/issues/1809). 2387 2388- Improved error reporting for unformattable types: now you\'ll get 2389 the type name directly in the error message instead of the note: 2390 2391 ```c++ 2392 #include <fmt/core.h> 2393 2394 struct how_about_no {}; 2395 2396 int main() { 2397 fmt::print("{}", how_about_no()); 2398 } 2399 ``` 2400 2401 Error ([godbolt](https://godbolt.org/z/GoxM4e)): 2402 2403 `fmt/core.h:1438:3: error: static_assert failed due to requirement 'fmt::v7::formattable<how_about_no>()' "Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt" ...` 2404 2405- Added the 2406 [make_args_checked](https://fmt.dev/7.1.0/api.html#argument-lists) 2407 function template that allows you to write formatting functions with 2408 compile-time format string checks and avoid binary code bloat 2409 ([godbolt](https://godbolt.org/z/PEf9qr)): 2410 2411 ```c++ 2412 void vlog(const char* file, int line, fmt::string_view format, 2413 fmt::format_args args) { 2414 fmt::print("{}: {}: ", file, line); 2415 fmt::vprint(format, args); 2416 } 2417 2418 template <typename S, typename... Args> 2419 void log(const char* file, int line, const S& format, Args&&... args) { 2420 vlog(file, line, format, 2421 fmt::make_args_checked<Args...>(format, args...)); 2422 } 2423 2424 #define MY_LOG(format, ...) \ 2425 log(__FILE__, __LINE__, FMT_STRING(format), __VA_ARGS__) 2426 2427 MY_LOG("invalid squishiness: {}", 42); 2428 ``` 2429 2430- Replaced `snprintf` fallback with a faster internal IEEE 754 `float` 2431 and `double` formatter for arbitrary precision. For example 2432 ([godbolt](https://godbolt.org/z/dPhWvj)): 2433 2434 ```c++ 2435 #include <fmt/core.h> 2436 2437 int main() { 2438 fmt::print("{:.500}\n", 4.9406564584124654E-324); 2439 } 2440 ``` 2441 2442 prints 2443 2444 `4.9406564584124654417656879286822137236505980261432476442558568250067550727020875186529983636163599237979656469544571773092665671035593979639877479601078187812630071319031140452784581716784898210368871863605699873072305000638740915356498438731247339727316961514003171538539807412623856559117102665855668676818703956031062493194527159149245532930545654440112748012970999954193198940908041656332452475714786901472678015935523861155013480352649347201937902681071074917033322268447533357208324319360923829e-324`. 2445 2446- Made `format_to_n` and `formatted_size` part of the [core 2447 API](https://fmt.dev/latest/api.html#core-api) 2448 ([godbolt](https://godbolt.org/z/sPjY1K)): 2449 2450 ```c++ 2451 #include <fmt/core.h> 2452 2453 int main() { 2454 char buffer[10]; 2455 auto result = fmt::format_to_n(buffer, sizeof(buffer), "{}", 42); 2456 } 2457 ``` 2458 2459- Added `fmt::format_to_n` overload with format string compilation 2460 (https://github.com/fmtlib/fmt/issues/1764, 2461 https://github.com/fmtlib/fmt/pull/1767, 2462 https://github.com/fmtlib/fmt/pull/1869). For example 2463 ([godbolt](https://godbolt.org/z/93h86q)): 2464 2465 ```c++ 2466 #include <fmt/compile.h> 2467 2468 int main() { 2469 char buffer[8]; 2470 fmt::format_to_n(buffer, sizeof(buffer), FMT_COMPILE("{}"), 42); 2471 } 2472 ``` 2473 2474 Thanks @Kurkin and @alexezeder. 2475 2476- Added `fmt::format_to` overload that take `text_style` 2477 (https://github.com/fmtlib/fmt/issues/1593, 2478 https://github.com/fmtlib/fmt/issues/1842, 2479 https://github.com/fmtlib/fmt/pull/1843). For example 2480 ([godbolt](https://godbolt.org/z/91153r)): 2481 2482 ```c++ 2483 #include <fmt/color.h> 2484 2485 int main() { 2486 std::string out; 2487 fmt::format_to(std::back_inserter(out), 2488 fmt::emphasis::bold | fg(fmt::color::red), 2489 "The answer is {}.", 42); 2490 } 2491 ``` 2492 2493 Thanks @Naios. 2494 2495- Made the `'#'` specifier emit trailing zeros in addition to the 2496 decimal point (https://github.com/fmtlib/fmt/issues/1797). 2497 For example ([godbolt](https://godbolt.org/z/bhdcW9)): 2498 2499 ```c++ 2500 #include <fmt/core.h> 2501 2502 int main() { 2503 fmt::print("{:#.2g}", 0.5); 2504 } 2505 ``` 2506 2507 prints `0.50`. 2508 2509- Changed the default floating point format to not include `.0` for 2510 consistency with `std::format` and `std::to_chars` 2511 (https://github.com/fmtlib/fmt/issues/1893, 2512 https://github.com/fmtlib/fmt/issues/1943). It is possible 2513 to get the decimal point and trailing zero with the `#` specifier. 2514 2515- Fixed an issue with floating-point formatting that could result in 2516 addition of a non-significant trailing zero in rare cases e.g. 2517 `1.00e-34` instead of `1.0e-34` 2518 (https://github.com/fmtlib/fmt/issues/1873, 2519 https://github.com/fmtlib/fmt/issues/1917). 2520 2521- Made `fmt::to_string` fallback on `ostream` insertion operator if 2522 the `formatter` specialization is not provided 2523 (https://github.com/fmtlib/fmt/issues/1815, 2524 https://github.com/fmtlib/fmt/pull/1829). Thanks @alexezeder. 2525 2526- Added support for the append mode to the experimental file API and 2527 improved `fcntl.h` detection. 2528 (https://github.com/fmtlib/fmt/pull/1847, 2529 https://github.com/fmtlib/fmt/pull/1848). Thanks @t-wiser. 2530 2531- Fixed handling of types that have both an implicit conversion 2532 operator and an overloaded `ostream` insertion operator 2533 (https://github.com/fmtlib/fmt/issues/1766). 2534 2535- Fixed a slicing issue in an internal iterator type 2536 (https://github.com/fmtlib/fmt/pull/1822). Thanks @BRevzin. 2537 2538- Fixed an issue in locale-specific integer formatting 2539 (https://github.com/fmtlib/fmt/issues/1927). 2540 2541- Fixed handling of exotic code unit types 2542 (https://github.com/fmtlib/fmt/issues/1870, 2543 https://github.com/fmtlib/fmt/issues/1932). 2544 2545- Improved `FMT_ALWAYS_INLINE` 2546 (https://github.com/fmtlib/fmt/pull/1878). Thanks @jk-jeon. 2547 2548- Removed dependency on `windows.h` 2549 (https://github.com/fmtlib/fmt/pull/1900). Thanks @bernd5. 2550 2551- Optimized counting of decimal digits on MSVC 2552 (https://github.com/fmtlib/fmt/pull/1890). Thanks @mwinterb. 2553 2554- Improved documentation 2555 (https://github.com/fmtlib/fmt/issues/1772, 2556 https://github.com/fmtlib/fmt/pull/1775, 2557 https://github.com/fmtlib/fmt/pull/1792, 2558 https://github.com/fmtlib/fmt/pull/1838, 2559 https://github.com/fmtlib/fmt/pull/1888, 2560 https://github.com/fmtlib/fmt/pull/1918, 2561 https://github.com/fmtlib/fmt/pull/1939). 2562 Thanks @leolchat, @pepsiman, @Klaim, @ravijanjam, @francesco-st and @udnaan. 2563 2564- Added the `FMT_REDUCE_INT_INSTANTIATIONS` CMake option that reduces 2565 the binary code size at the cost of some integer formatting 2566 performance. This can be useful for extremely memory-constrained 2567 embedded systems 2568 (https://github.com/fmtlib/fmt/issues/1778, 2569 https://github.com/fmtlib/fmt/pull/1781). Thanks @kammce. 2570 2571- Added the `FMT_USE_INLINE_NAMESPACES` macro to control usage of 2572 inline namespaces 2573 (https://github.com/fmtlib/fmt/pull/1945). Thanks @darklukee. 2574 2575- Improved build configuration 2576 (https://github.com/fmtlib/fmt/pull/1760, 2577 https://github.com/fmtlib/fmt/pull/1770, 2578 https://github.com/fmtlib/fmt/issues/1779, 2579 https://github.com/fmtlib/fmt/pull/1783, 2580 https://github.com/fmtlib/fmt/pull/1823). 2581 Thanks @dvetutnev, @xvitaly, @tambry, @medithe and @martinwuehrer. 2582 2583- Fixed various warnings and compilation issues 2584 (https://github.com/fmtlib/fmt/pull/1790, 2585 https://github.com/fmtlib/fmt/pull/1802, 2586 https://github.com/fmtlib/fmt/pull/1808, 2587 https://github.com/fmtlib/fmt/issues/1810, 2588 https://github.com/fmtlib/fmt/issues/1811, 2589 https://github.com/fmtlib/fmt/pull/1812, 2590 https://github.com/fmtlib/fmt/pull/1814, 2591 https://github.com/fmtlib/fmt/pull/1816, 2592 https://github.com/fmtlib/fmt/pull/1817, 2593 https://github.com/fmtlib/fmt/pull/1818, 2594 https://github.com/fmtlib/fmt/issues/1825, 2595 https://github.com/fmtlib/fmt/pull/1836, 2596 https://github.com/fmtlib/fmt/pull/1855, 2597 https://github.com/fmtlib/fmt/pull/1856, 2598 https://github.com/fmtlib/fmt/pull/1860, 2599 https://github.com/fmtlib/fmt/pull/1877, 2600 https://github.com/fmtlib/fmt/pull/1879, 2601 https://github.com/fmtlib/fmt/pull/1880, 2602 https://github.com/fmtlib/fmt/issues/1896, 2603 https://github.com/fmtlib/fmt/pull/1897, 2604 https://github.com/fmtlib/fmt/pull/1898, 2605 https://github.com/fmtlib/fmt/issues/1904, 2606 https://github.com/fmtlib/fmt/pull/1908, 2607 https://github.com/fmtlib/fmt/issues/1911, 2608 https://github.com/fmtlib/fmt/issues/1912, 2609 https://github.com/fmtlib/fmt/issues/1928, 2610 https://github.com/fmtlib/fmt/pull/1929, 2611 https://github.com/fmtlib/fmt/issues/1935, 2612 https://github.com/fmtlib/fmt/pull/1937, 2613 https://github.com/fmtlib/fmt/pull/1942, 2614 https://github.com/fmtlib/fmt/issues/1949). 2615 Thanks @TheQwertiest, @medithe, @martinwuehrer, @n16h7hunt3r, @Othereum, 2616 @gsjaardema, @AlexanderLanin, @gcerretani, @chronoxor, @noizefloor, 2617 @akohlmey, @jk-jeon, @rimathia, @rglarix, @moiwi, @heckad, @MarcDirven. 2618 @BartSiwek and @darklukee. 2619 2620# 7.0.3 - 2020-08-06 2621 2622- Worked around broken `numeric_limits` for 128-bit integers 2623 (https://github.com/fmtlib/fmt/issues/1787). 2624- Added error reporting on missing named arguments 2625 (https://github.com/fmtlib/fmt/issues/1796). 2626- Stopped using 128-bit integers with clang-cl 2627 (https://github.com/fmtlib/fmt/pull/1800). Thanks @Kingcom. 2628- Fixed issues in locale-specific integer formatting 2629 (https://github.com/fmtlib/fmt/issues/1782, 2630 https://github.com/fmtlib/fmt/issues/1801). 2631 2632# 7.0.2 - 2020-07-29 2633 2634- Worked around broken `numeric_limits` for 128-bit integers 2635 (https://github.com/fmtlib/fmt/issues/1725). 2636- Fixed compatibility with CMake 3.4 2637 (https://github.com/fmtlib/fmt/issues/1779). 2638- Fixed handling of digit separators in locale-specific formatting 2639 (https://github.com/fmtlib/fmt/issues/1782). 2640 2641# 7.0.1 - 2020-07-07 2642 2643- Updated the inline version namespace name. 2644- Worked around a gcc bug in mangling of alias templates 2645 (https://github.com/fmtlib/fmt/issues/1753). 2646- Fixed a linkage error on Windows 2647 (https://github.com/fmtlib/fmt/issues/1757). Thanks @Kurkin. 2648- Fixed minor issues with the documentation. 2649 2650# 7.0.0 - 2020-07-05 2651 2652- Reduced the library size. For example, on macOS a stripped test 2653 binary statically linked with {fmt} [shrank from \~368k to less than 2654 100k](http://www.zverovich.net/2020/05/21/reducing-library-size.html). 2655 2656- Added a simpler and more efficient [format string compilation 2657 API](https://fmt.dev/7.0.0/api.html#compile-api): 2658 2659 ```c++ 2660 #include <fmt/compile.h> 2661 2662 // Converts 42 into std::string using the most efficient method and no 2663 // runtime format string processing. 2664 std::string s = fmt::format(FMT_COMPILE("{}"), 42); 2665 ``` 2666 2667 The old `fmt::compile` API is now deprecated. 2668 2669- Optimized integer formatting: `format_to` with format string 2670 compilation and a stack-allocated buffer is now [faster than 2671 to_chars on both libc++ and 2672 libstdc++](http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html). 2673 2674- Optimized handling of small format strings. For example, 2675 2676 ```c++ 2677 fmt::format("Result: {}: ({},{},{},{})", str1, str2, str3, str4, str5) 2678 ``` 2679 2680 is now \~40% faster 2681 (https://github.com/fmtlib/fmt/issues/1685). 2682 2683- Applied extern templates to improve compile times when using the 2684 core API and `fmt/format.h` 2685 (https://github.com/fmtlib/fmt/issues/1452). For example, 2686 on macOS with clang the compile time of a test translation unit 2687 dropped from 2.3s to 0.3s with `-O2` and from 0.6s to 0.3s with the 2688 default settings (`-O0`). 2689 2690 Before (`-O2`): 2691 2692 % time c++ -c test.cc -I include -std=c++17 -O2 2693 c++ -c test.cc -I include -std=c++17 -O2 2.22s user 0.08s system 99% cpu 2.311 total 2694 2695 After (`-O2`): 2696 2697 % time c++ -c test.cc -I include -std=c++17 -O2 2698 c++ -c test.cc -I include -std=c++17 -O2 0.26s user 0.04s system 98% cpu 0.303 total 2699 2700 Before (default): 2701 2702 % time c++ -c test.cc -I include -std=c++17 2703 c++ -c test.cc -I include -std=c++17 0.53s user 0.06s system 98% cpu 0.601 total 2704 2705 After (default): 2706 2707 % time c++ -c test.cc -I include -std=c++17 2708 c++ -c test.cc -I include -std=c++17 0.24s user 0.06s system 98% cpu 0.301 total 2709 2710 It is still recommended to use `fmt/core.h` instead of 2711 `fmt/format.h` but the compile time difference is now smaller. 2712 Thanks @alex3d for the suggestion. 2713 2714- Named arguments are now stored on stack (no dynamic memory 2715 allocations) and the compiled code is more compact and efficient. 2716 For example 2717 2718 ```c++ 2719 #include <fmt/core.h> 2720 2721 int main() { 2722 fmt::print("The answer is {answer}\n", fmt::arg("answer", 42)); 2723 } 2724 ``` 2725 2726 compiles to just ([godbolt](https://godbolt.org/z/NcfEp_)) 2727 2728 ```asm 2729 .LC0: 2730 .string "answer" 2731 .LC1: 2732 .string "The answer is {answer}\n" 2733 main: 2734 sub rsp, 56 2735 mov edi, OFFSET FLAT:.LC1 2736 mov esi, 23 2737 movabs rdx, 4611686018427387905 2738 lea rax, [rsp+32] 2739 lea rcx, [rsp+16] 2740 mov QWORD PTR [rsp+8], 1 2741 mov QWORD PTR [rsp], rax 2742 mov DWORD PTR [rsp+16], 42 2743 mov QWORD PTR [rsp+32], OFFSET FLAT:.LC0 2744 mov DWORD PTR [rsp+40], 0 2745 call fmt::v6::vprint(fmt::v6::basic_string_view<char>, 2746 fmt::v6::format_args) 2747 xor eax, eax 2748 add rsp, 56 2749 ret 2750 2751 .L.str.1: 2752 .asciz "answer" 2753 ``` 2754 2755- Implemented compile-time checks for dynamic width and precision 2756 (https://github.com/fmtlib/fmt/issues/1614): 2757 2758 ```c++ 2759 #include <fmt/format.h> 2760 2761 int main() { 2762 fmt::print(FMT_STRING("{0:{1}}"), 42); 2763 } 2764 ``` 2765 2766 now gives a compilation error because argument 1 doesn\'t exist: 2767 2768 In file included from test.cc:1: 2769 include/fmt/format.h:2726:27: error: constexpr variable 'invalid_format' must be 2770 initialized by a constant expression 2771 FMT_CONSTEXPR_DECL bool invalid_format = 2772 ^ 2773 ... 2774 include/fmt/core.h:569:26: note: in call to 2775 '&checker(s, {}).context_->on_error(&"argument not found"[0])' 2776 if (id >= num_args_) on_error("argument not found"); 2777 ^ 2778 2779- Added sentinel support to `fmt::join` 2780 (https://github.com/fmtlib/fmt/pull/1689) 2781 2782 ```c++ 2783 struct zstring_sentinel {}; 2784 bool operator==(const char* p, zstring_sentinel) { return *p == '\0'; } 2785 bool operator!=(const char* p, zstring_sentinel) { return *p != '\0'; } 2786 2787 struct zstring { 2788 const char* p; 2789 const char* begin() const { return p; } 2790 zstring_sentinel end() const { return {}; } 2791 }; 2792 2793 auto s = fmt::format("{}", fmt::join(zstring{"hello"}, "_")); 2794 // s == "h_e_l_l_o" 2795 ``` 2796 2797 Thanks @BRevzin. 2798 2799- Added support for named arguments, `clear` and `reserve` to 2800 `dynamic_format_arg_store` 2801 (https://github.com/fmtlib/fmt/issues/1655, 2802 https://github.com/fmtlib/fmt/pull/1663, 2803 https://github.com/fmtlib/fmt/pull/1674, 2804 https://github.com/fmtlib/fmt/pull/1677). Thanks @vsolontsov-ll. 2805 2806- Added support for the `'c'` format specifier to integral types for 2807 compatibility with `std::format` 2808 (https://github.com/fmtlib/fmt/issues/1652). 2809 2810- Replaced the `'n'` format specifier with `'L'` for compatibility 2811 with `std::format` 2812 (https://github.com/fmtlib/fmt/issues/1624). The `'n'` 2813 specifier can be enabled via the `FMT_DEPRECATED_N_SPECIFIER` macro. 2814 2815- The `'='` format specifier is now disabled by default for 2816 compatibility with `std::format`. It can be enabled via the 2817 `FMT_DEPRECATED_NUMERIC_ALIGN` macro. 2818 2819- Removed the following deprecated APIs: 2820 2821 - `FMT_STRING_ALIAS` and `fmt` macros - replaced by `FMT_STRING` 2822 - `fmt::basic_string_view::char_type` - replaced by 2823 `fmt::basic_string_view::value_type` 2824 - `convert_to_int` 2825 - `format_arg_store::types` 2826 - `*parse_context` - replaced by `*format_parse_context` 2827 - `FMT_DEPRECATED_INCLUDE_OS` 2828 - `FMT_DEPRECATED_PERCENT` - incompatible with `std::format` 2829 - `*writer` - replaced by compiled format API 2830 2831- Renamed the `internal` namespace to `detail` 2832 (https://github.com/fmtlib/fmt/issues/1538). The former is 2833 still provided as an alias if the `FMT_USE_INTERNAL` macro is 2834 defined. 2835 2836- Improved compatibility between `fmt::printf` with the standard specs 2837 (https://github.com/fmtlib/fmt/issues/1595, 2838 https://github.com/fmtlib/fmt/pull/1682, 2839 https://github.com/fmtlib/fmt/pull/1683, 2840 https://github.com/fmtlib/fmt/pull/1687, 2841 https://github.com/fmtlib/fmt/pull/1699). Thanks @rimathia. 2842 2843- Fixed handling of `operator<<` overloads that use `copyfmt` 2844 (https://github.com/fmtlib/fmt/issues/1666). 2845 2846- Added the `FMT_OS` CMake option to control inclusion of OS-specific 2847 APIs in the fmt target. This can be useful for embedded platforms 2848 (https://github.com/fmtlib/fmt/issues/1654, 2849 https://github.com/fmtlib/fmt/pull/1656). Thanks @kwesolowski. 2850 2851- Replaced `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` with the 2852 `FMT_FUZZ` macro to prevent interfering with fuzzing of projects 2853 using {fmt} (https://github.com/fmtlib/fmt/pull/1650). 2854 Thanks @asraa. 2855 2856- Fixed compatibility with emscripten 2857 (https://github.com/fmtlib/fmt/issues/1636, 2858 https://github.com/fmtlib/fmt/pull/1637). Thanks @ArthurSonzogni. 2859 2860- Improved documentation 2861 (https://github.com/fmtlib/fmt/issues/704, 2862 https://github.com/fmtlib/fmt/pull/1643, 2863 https://github.com/fmtlib/fmt/pull/1660, 2864 https://github.com/fmtlib/fmt/pull/1681, 2865 https://github.com/fmtlib/fmt/pull/1691, 2866 https://github.com/fmtlib/fmt/pull/1706, 2867 https://github.com/fmtlib/fmt/pull/1714, 2868 https://github.com/fmtlib/fmt/pull/1721, 2869 https://github.com/fmtlib/fmt/pull/1739, 2870 https://github.com/fmtlib/fmt/pull/1740, 2871 https://github.com/fmtlib/fmt/pull/1741, 2872 https://github.com/fmtlib/fmt/pull/1751). 2873 Thanks @senior7515, @lsr0, @puetzk, @fpelliccioni, Alexey Kuzmenko, @jelly, 2874 @claremacrae, @jiapengwen, @gsjaardema and @alexey-milovidov. 2875 2876- Implemented various build configuration fixes and improvements 2877 (https://github.com/fmtlib/fmt/pull/1603, 2878 https://github.com/fmtlib/fmt/pull/1657, 2879 https://github.com/fmtlib/fmt/pull/1702, 2880 https://github.com/fmtlib/fmt/pull/1728). 2881 Thanks @scramsby, @jtojnar, @orivej and @flagarde. 2882 2883- Fixed various warnings and compilation issues 2884 (https://github.com/fmtlib/fmt/pull/1616, 2885 https://github.com/fmtlib/fmt/issues/1620, 2886 https://github.com/fmtlib/fmt/issues/1622, 2887 https://github.com/fmtlib/fmt/issues/1625, 2888 https://github.com/fmtlib/fmt/pull/1627, 2889 https://github.com/fmtlib/fmt/issues/1628, 2890 https://github.com/fmtlib/fmt/pull/1629, 2891 https://github.com/fmtlib/fmt/issues/1631, 2892 https://github.com/fmtlib/fmt/pull/1633, 2893 https://github.com/fmtlib/fmt/pull/1649, 2894 https://github.com/fmtlib/fmt/issues/1658, 2895 https://github.com/fmtlib/fmt/pull/1661, 2896 https://github.com/fmtlib/fmt/pull/1667, 2897 https://github.com/fmtlib/fmt/issues/1668, 2898 https://github.com/fmtlib/fmt/pull/1669, 2899 https://github.com/fmtlib/fmt/issues/1692, 2900 https://github.com/fmtlib/fmt/pull/1696, 2901 https://github.com/fmtlib/fmt/pull/1697, 2902 https://github.com/fmtlib/fmt/issues/1707, 2903 https://github.com/fmtlib/fmt/pull/1712, 2904 https://github.com/fmtlib/fmt/pull/1716, 2905 https://github.com/fmtlib/fmt/pull/1722, 2906 https://github.com/fmtlib/fmt/issues/1724, 2907 https://github.com/fmtlib/fmt/pull/1729, 2908 https://github.com/fmtlib/fmt/pull/1738, 2909 https://github.com/fmtlib/fmt/issues/1742, 2910 https://github.com/fmtlib/fmt/issues/1743, 2911 https://github.com/fmtlib/fmt/pull/1744, 2912 https://github.com/fmtlib/fmt/issues/1747, 2913 https://github.com/fmtlib/fmt/pull/1750). 2914 Thanks @gsjaardema, @gabime, @johnor, @Kurkin, @invexed, @peterbell10, 2915 @daixtrose, @petrutlucian94, @Neargye, @ambitslix, @gabime, @erthink, 2916 @tohammer and @0x8000-0000. 2917 2918# 6.2.1 - 2020-05-09 2919 2920- Fixed ostream support in `sprintf` 2921 (https://github.com/fmtlib/fmt/issues/1631). 2922- Fixed type detection when using implicit conversion to `string_view` 2923 and ostream `operator<<` inconsistently 2924 (https://github.com/fmtlib/fmt/issues/1662). 2925 2926# 6.2.0 - 2020-04-05 2927 2928- Improved error reporting when trying to format an object of a 2929 non-formattable type: 2930 2931 ```c++ 2932 fmt::format("{}", S()); 2933 ``` 2934 2935 now gives: 2936 2937 include/fmt/core.h:1015:5: error: static_assert failed due to requirement 2938 'formattable' "Cannot format argument. To make type T formattable provide a 2939 formatter<T> specialization: 2940 https://fmt.dev/latest/api.html#formatting-user-defined-types" 2941 static_assert( 2942 ^ 2943 ... 2944 note: in instantiation of function template specialization 2945 'fmt::v6::format<char [3], S, char>' requested here 2946 fmt::format("{}", S()); 2947 ^ 2948 2949 if `S` is not formattable. 2950 2951- Reduced the library size by \~10%. 2952 2953- Always print decimal point if `#` is specified 2954 (https://github.com/fmtlib/fmt/issues/1476, 2955 https://github.com/fmtlib/fmt/issues/1498): 2956 2957 ```c++ 2958 fmt::print("{:#.0f}", 42.0); 2959 ``` 2960 2961 now prints `42.` 2962 2963- Implemented the `'L'` specifier for locale-specific numeric 2964 formatting to improve compatibility with `std::format`. The `'n'` 2965 specifier is now deprecated and will be removed in the next major 2966 release. 2967 2968- Moved OS-specific APIs such as `windows_error` from `fmt/format.h` 2969 to `fmt/os.h`. You can define `FMT_DEPRECATED_INCLUDE_OS` to 2970 automatically include `fmt/os.h` from `fmt/format.h` for 2971 compatibility but this will be disabled in the next major release. 2972 2973- Added precision overflow detection in floating-point formatting. 2974 2975- Implemented detection of invalid use of `fmt::arg`. 2976 2977- Used `type_identity` to block unnecessary template argument 2978 deduction. Thanks Tim Song. 2979 2980- Improved UTF-8 handling 2981 (https://github.com/fmtlib/fmt/issues/1109): 2982 2983 ```c++ 2984 fmt::print("┌{0:─^{2}}┐\n" 2985 "│{1: ^{2}}│\n" 2986 "└{0:─^{2}}┘\n", "", "Привет, мир!", 20); 2987 ``` 2988 2989 now prints: 2990 2991 ┌────────────────────┐ 2992 │ Привет, мир! │ 2993 └────────────────────┘ 2994 2995 on systems that support Unicode. 2996 2997- Added experimental dynamic argument storage 2998 (https://github.com/fmtlib/fmt/issues/1170, 2999 https://github.com/fmtlib/fmt/pull/1584): 3000 3001 ```c++ 3002 fmt::dynamic_format_arg_store<fmt::format_context> store; 3003 store.push_back("answer"); 3004 store.push_back(42); 3005 fmt::vprint("The {} is {}.\n", store); 3006 ``` 3007 3008 prints: 3009 3010 The answer is 42. 3011 3012 Thanks @vsolontsov-ll. 3013 3014- Made `fmt::join` accept `initializer_list` 3015 (https://github.com/fmtlib/fmt/pull/1591). Thanks @Rapotkinnik. 3016 3017- Fixed handling of empty tuples 3018 (https://github.com/fmtlib/fmt/issues/1588). 3019 3020- Fixed handling of output iterators in `format_to_n` 3021 (https://github.com/fmtlib/fmt/issues/1506). 3022 3023- Fixed formatting of `std::chrono::duration` types to wide output 3024 (https://github.com/fmtlib/fmt/pull/1533). Thanks @zeffy. 3025 3026- Added const `begin` and `end` overload to buffers 3027 (https://github.com/fmtlib/fmt/pull/1553). Thanks @dominicpoeschko. 3028 3029- Added the ability to disable floating-point formatting via 3030 `FMT_USE_FLOAT`, `FMT_USE_DOUBLE` and `FMT_USE_LONG_DOUBLE` macros 3031 for extremely memory-constrained embedded system 3032 (https://github.com/fmtlib/fmt/pull/1590). Thanks @albaguirre. 3033 3034- Made `FMT_STRING` work with `constexpr` `string_view` 3035 (https://github.com/fmtlib/fmt/pull/1589). Thanks @scramsby. 3036 3037- Implemented a minor optimization in the format string parser 3038 (https://github.com/fmtlib/fmt/pull/1560). Thanks @IkarusDeveloper. 3039 3040- Improved attribute detection 3041 (https://github.com/fmtlib/fmt/pull/1469, 3042 https://github.com/fmtlib/fmt/pull/1475, 3043 https://github.com/fmtlib/fmt/pull/1576). 3044 Thanks @federico-busato, @chronoxor and @refnum. 3045 3046- Improved documentation 3047 (https://github.com/fmtlib/fmt/pull/1481, 3048 https://github.com/fmtlib/fmt/pull/1523). 3049 Thanks @JackBoosY and @imba-tjd. 3050 3051- Fixed symbol visibility on Linux when compiling with 3052 `-fvisibility=hidden` 3053 (https://github.com/fmtlib/fmt/pull/1535). Thanks @milianw. 3054 3055- Implemented various build configuration fixes and improvements 3056 (https://github.com/fmtlib/fmt/issues/1264, 3057 https://github.com/fmtlib/fmt/issues/1460, 3058 https://github.com/fmtlib/fmt/pull/1534, 3059 https://github.com/fmtlib/fmt/issues/1536, 3060 https://github.com/fmtlib/fmt/issues/1545, 3061 https://github.com/fmtlib/fmt/pull/1546, 3062 https://github.com/fmtlib/fmt/issues/1566, 3063 https://github.com/fmtlib/fmt/pull/1582, 3064 https://github.com/fmtlib/fmt/issues/1597, 3065 https://github.com/fmtlib/fmt/pull/1598). 3066 Thanks @ambitslix, @jwillikers and @stac47. 3067 3068- Fixed various warnings and compilation issues 3069 (https://github.com/fmtlib/fmt/pull/1433, 3070 https://github.com/fmtlib/fmt/issues/1461, 3071 https://github.com/fmtlib/fmt/pull/1470, 3072 https://github.com/fmtlib/fmt/pull/1480, 3073 https://github.com/fmtlib/fmt/pull/1485, 3074 https://github.com/fmtlib/fmt/pull/1492, 3075 https://github.com/fmtlib/fmt/issues/1493, 3076 https://github.com/fmtlib/fmt/issues/1504, 3077 https://github.com/fmtlib/fmt/pull/1505, 3078 https://github.com/fmtlib/fmt/pull/1512, 3079 https://github.com/fmtlib/fmt/issues/1515, 3080 https://github.com/fmtlib/fmt/pull/1516, 3081 https://github.com/fmtlib/fmt/pull/1518, 3082 https://github.com/fmtlib/fmt/pull/1519, 3083 https://github.com/fmtlib/fmt/pull/1520, 3084 https://github.com/fmtlib/fmt/pull/1521, 3085 https://github.com/fmtlib/fmt/pull/1522, 3086 https://github.com/fmtlib/fmt/issues/1524, 3087 https://github.com/fmtlib/fmt/pull/1530, 3088 https://github.com/fmtlib/fmt/issues/1531, 3089 https://github.com/fmtlib/fmt/pull/1532, 3090 https://github.com/fmtlib/fmt/issues/1539, 3091 https://github.com/fmtlib/fmt/issues/1547, 3092 https://github.com/fmtlib/fmt/issues/1548, 3093 https://github.com/fmtlib/fmt/pull/1554, 3094 https://github.com/fmtlib/fmt/issues/1567, 3095 https://github.com/fmtlib/fmt/pull/1568, 3096 https://github.com/fmtlib/fmt/pull/1569, 3097 https://github.com/fmtlib/fmt/pull/1571, 3098 https://github.com/fmtlib/fmt/pull/1573, 3099 https://github.com/fmtlib/fmt/pull/1575, 3100 https://github.com/fmtlib/fmt/pull/1581, 3101 https://github.com/fmtlib/fmt/issues/1583, 3102 https://github.com/fmtlib/fmt/issues/1586, 3103 https://github.com/fmtlib/fmt/issues/1587, 3104 https://github.com/fmtlib/fmt/issues/1594, 3105 https://github.com/fmtlib/fmt/pull/1596, 3106 https://github.com/fmtlib/fmt/issues/1604, 3107 https://github.com/fmtlib/fmt/pull/1606, 3108 https://github.com/fmtlib/fmt/issues/1607, 3109 https://github.com/fmtlib/fmt/issues/1609). 3110 Thanks @marti4d, @iPherian, @parkertomatoes, @gsjaardema, @chronoxor, 3111 @DanielaE, @torsten48, @tohammer, @lefticus, @ryusakki, @adnsv, @fghzxm, 3112 @refnum, @pramodk, @Spirrwell and @scramsby. 3113 3114# 6.1.2 - 2019-12-11 3115 3116- Fixed ABI compatibility with `libfmt.so.6.0.0` 3117 (https://github.com/fmtlib/fmt/issues/1471). 3118- Fixed handling types convertible to `std::string_view` 3119 (https://github.com/fmtlib/fmt/pull/1451). Thanks @denizevrenci. 3120- Made CUDA test an opt-in enabled via the `FMT_CUDA_TEST` CMake 3121 option. 3122- Fixed sign conversion warnings 3123 (https://github.com/fmtlib/fmt/pull/1440). Thanks @0x8000-0000. 3124 3125# 6.1.1 - 2019-12-04 3126 3127- Fixed shared library build on Windows 3128 (https://github.com/fmtlib/fmt/pull/1443, 3129 https://github.com/fmtlib/fmt/issues/1445, 3130 https://github.com/fmtlib/fmt/pull/1446, 3131 https://github.com/fmtlib/fmt/issues/1450). 3132 Thanks @egorpugin and @bbolli. 3133- Added a missing decimal point in exponent notation with trailing 3134 zeros. 3135- Removed deprecated `format_arg_store::TYPES`. 3136 3137# 6.1.0 - 2019-12-01 3138 3139- {fmt} now formats IEEE 754 `float` and `double` using the shortest 3140 decimal representation with correct rounding by default: 3141 3142 ```c++ 3143 #include <cmath> 3144 #include <fmt/core.h> 3145 3146 int main() { 3147 fmt::print("{}", M_PI); 3148 } 3149 ``` 3150 3151 prints `3.141592653589793`. 3152 3153- Made the fast binary to decimal floating-point formatter the 3154 default, simplified it and improved performance. {fmt} is now 15 3155 times faster than libc++\'s `std::ostringstream`, 11 times faster 3156 than `printf` and 10% faster than double-conversion on 3157 [dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark): 3158 3159 | Function | Time (ns) | Speedup | 3160 | ------------- | --------: | ------: | 3161 | ostringstream | 1,346.30 | 1.00x | 3162 | ostrstream | 1,195.74 | 1.13x | 3163 | sprintf | 995.08 | 1.35x | 3164 | doubleconv | 99.10 | 13.59x | 3165 | fmt | 88.34 | 15.24x | 3166 3167  3168 3169- {fmt} no longer converts `float` arguments to `double`. In 3170 particular this improves the default (shortest) representation of 3171 floats and makes `fmt::format` consistent with `std::format` specs 3172 (https://github.com/fmtlib/fmt/issues/1336, 3173 https://github.com/fmtlib/fmt/issues/1353, 3174 https://github.com/fmtlib/fmt/pull/1360, 3175 https://github.com/fmtlib/fmt/pull/1361): 3176 3177 ```c++ 3178 fmt::print("{}", 0.1f); 3179 ``` 3180 3181 prints `0.1` instead of `0.10000000149011612`. 3182 3183 Thanks @orivej. 3184 3185- Made floating-point formatting output consistent with 3186 `printf`/iostreams 3187 (https://github.com/fmtlib/fmt/issues/1376, 3188 https://github.com/fmtlib/fmt/issues/1417). 3189 3190- Added support for 128-bit integers 3191 (https://github.com/fmtlib/fmt/pull/1287): 3192 3193 ```c++ 3194 fmt::print("{}", std::numeric_limits<__int128_t>::max()); 3195 ``` 3196 3197 prints `170141183460469231731687303715884105727`. 3198 3199 Thanks @denizevrenci. 3200 3201- The overload of `print` that takes `text_style` is now atomic, i.e. 3202 the output from different threads doesn\'t interleave 3203 (https://github.com/fmtlib/fmt/pull/1351). Thanks @tankiJong. 3204 3205- Made compile time in the header-only mode \~20% faster by reducing 3206 the number of template instantiations. `wchar_t` overload of 3207 `vprint` was moved from `fmt/core.h` to `fmt/format.h`. 3208 3209- Added an overload of `fmt::join` that works with tuples 3210 (https://github.com/fmtlib/fmt/issues/1322, 3211 https://github.com/fmtlib/fmt/pull/1330): 3212 3213 ```c++ 3214 #include <tuple> 3215 #include <fmt/ranges.h> 3216 3217 int main() { 3218 std::tuple<char, int, float> t{'a', 1, 2.0f}; 3219 fmt::print("{}", t); 3220 } 3221 ``` 3222 3223 prints `('a', 1, 2.0)`. 3224 3225 Thanks @jeremyong. 3226 3227- Changed formatting of octal zero with prefix from \"00\" to \"0\": 3228 3229 ```c++ 3230 fmt::print("{:#o}", 0); 3231 ``` 3232 3233 prints `0`. 3234 3235- The locale is now passed to ostream insertion (`<<`) operators 3236 (https://github.com/fmtlib/fmt/pull/1406): 3237 3238 ```c++ 3239 #include <fmt/locale.h> 3240 #include <fmt/ostream.h> 3241 3242 struct S { 3243 double value; 3244 }; 3245 3246 std::ostream& operator<<(std::ostream& os, S s) { 3247 return os << s.value; 3248 } 3249 3250 int main() { 3251 auto s = fmt::format(std::locale("fr_FR.UTF-8"), "{}", S{0.42}); 3252 // s == "0,42" 3253 } 3254 ``` 3255 3256 Thanks @dlaugt. 3257 3258- Locale-specific number formatting now uses grouping 3259 (https://github.com/fmtlib/fmt/issues/1393, 3260 https://github.com/fmtlib/fmt/pull/1394). Thanks @skrdaniel. 3261 3262- Fixed handling of types with deleted implicit rvalue conversion to 3263 `const char**` (https://github.com/fmtlib/fmt/issues/1421): 3264 3265 ```c++ 3266 struct mystring { 3267 operator const char*() const&; 3268 operator const char*() &; 3269 operator const char*() const&& = delete; 3270 operator const char*() && = delete; 3271 }; 3272 mystring str; 3273 fmt::print("{}", str); // now compiles 3274 ``` 3275 3276- Enums are now mapped to correct underlying types instead of `int` 3277 (https://github.com/fmtlib/fmt/pull/1286). Thanks @agmt. 3278 3279- Enum classes are no longer implicitly converted to `int` 3280 (https://github.com/fmtlib/fmt/issues/1424). 3281 3282- Added `basic_format_parse_context` for consistency with C++20 3283 `std::format` and deprecated `basic_parse_context`. 3284 3285- Fixed handling of UTF-8 in precision 3286 (https://github.com/fmtlib/fmt/issues/1389, 3287 https://github.com/fmtlib/fmt/pull/1390). Thanks @tajtiattila. 3288 3289- {fmt} can now be installed on Linux, macOS and Windows with 3290 [Conda](https://docs.conda.io/en/latest/) using its 3291 [conda-forge](https://conda-forge.org) 3292 [package](https://github.com/conda-forge/fmt-feedstock) 3293 (https://github.com/fmtlib/fmt/pull/1410): 3294 3295 conda install -c conda-forge fmt 3296 3297 Thanks @tdegeus. 3298 3299- Added a CUDA test (https://github.com/fmtlib/fmt/pull/1285, 3300 https://github.com/fmtlib/fmt/pull/1317). 3301 Thanks @luncliff and @risa2000. 3302 3303- Improved documentation 3304 (https://github.com/fmtlib/fmt/pull/1276, 3305 https://github.com/fmtlib/fmt/issues/1291, 3306 https://github.com/fmtlib/fmt/issues/1296, 3307 https://github.com/fmtlib/fmt/pull/1315, 3308 https://github.com/fmtlib/fmt/pull/1332, 3309 https://github.com/fmtlib/fmt/pull/1337, 3310 https://github.com/fmtlib/fmt/issues/1395 3311 https://github.com/fmtlib/fmt/pull/1418). 3312 Thanks @waywardmonkeys, @pauldreik and @jackoalan. 3313 3314- Various code improvements 3315 (https://github.com/fmtlib/fmt/pull/1358, 3316 https://github.com/fmtlib/fmt/pull/1407). 3317 Thanks @orivej and @dpacbach. 3318 3319- Fixed compile-time format string checks for user-defined types 3320 (https://github.com/fmtlib/fmt/issues/1292). 3321 3322- Worked around a false positive in `unsigned-integer-overflow` sanitizer 3323 (https://github.com/fmtlib/fmt/issues/1377). 3324 3325- Fixed various warnings and compilation issues 3326 (https://github.com/fmtlib/fmt/issues/1273, 3327 https://github.com/fmtlib/fmt/pull/1278, 3328 https://github.com/fmtlib/fmt/pull/1280, 3329 https://github.com/fmtlib/fmt/issues/1281, 3330 https://github.com/fmtlib/fmt/issues/1288, 3331 https://github.com/fmtlib/fmt/pull/1290, 3332 https://github.com/fmtlib/fmt/pull/1301, 3333 https://github.com/fmtlib/fmt/issues/1305, 3334 https://github.com/fmtlib/fmt/issues/1306, 3335 https://github.com/fmtlib/fmt/issues/1309, 3336 https://github.com/fmtlib/fmt/pull/1312, 3337 https://github.com/fmtlib/fmt/issues/1313, 3338 https://github.com/fmtlib/fmt/issues/1316, 3339 https://github.com/fmtlib/fmt/issues/1319, 3340 https://github.com/fmtlib/fmt/pull/1320, 3341 https://github.com/fmtlib/fmt/pull/1326, 3342 https://github.com/fmtlib/fmt/pull/1328, 3343 https://github.com/fmtlib/fmt/issues/1344, 3344 https://github.com/fmtlib/fmt/pull/1345, 3345 https://github.com/fmtlib/fmt/pull/1347, 3346 https://github.com/fmtlib/fmt/pull/1349, 3347 https://github.com/fmtlib/fmt/issues/1354, 3348 https://github.com/fmtlib/fmt/issues/1362, 3349 https://github.com/fmtlib/fmt/issues/1366, 3350 https://github.com/fmtlib/fmt/pull/1364, 3351 https://github.com/fmtlib/fmt/pull/1370, 3352 https://github.com/fmtlib/fmt/pull/1371, 3353 https://github.com/fmtlib/fmt/issues/1385, 3354 https://github.com/fmtlib/fmt/issues/1388, 3355 https://github.com/fmtlib/fmt/pull/1397, 3356 https://github.com/fmtlib/fmt/pull/1414, 3357 https://github.com/fmtlib/fmt/pull/1416, 3358 https://github.com/fmtlib/fmt/issues/1422 3359 https://github.com/fmtlib/fmt/pull/1427, 3360 https://github.com/fmtlib/fmt/issues/1431, 3361 https://github.com/fmtlib/fmt/pull/1433). 3362 Thanks @hhb, @gsjaardema, @gabime, @neheb, @vedranmiletic, @dkavolis, 3363 @mwinterb, @orivej, @denizevrenci, @leonklingele, @chronoxor, @kent-tri, 3364 @0x8000-0000 and @marti4d. 3365 3366# 6.0.0 - 2019-08-26 3367 3368- Switched to the [MIT license]( 3369 https://github.com/fmtlib/fmt/blob/5a4b24613ba16cc689977c3b5bd8274a3ba1dd1f/LICENSE.rst) 3370 with an optional exception that allows distributing binary code 3371 without attribution. 3372 3373- Floating-point formatting is now locale-independent by default: 3374 3375 ```c++ 3376 #include <locale> 3377 #include <fmt/core.h> 3378 3379 int main() { 3380 std::locale::global(std::locale("ru_RU.UTF-8")); 3381 fmt::print("value = {}", 4.2); 3382 } 3383 ``` 3384 3385 prints \"value = 4.2\" regardless of the locale. 3386 3387 For locale-specific formatting use the `n` specifier: 3388 3389 ```c++ 3390 std::locale::global(std::locale("ru_RU.UTF-8")); 3391 fmt::print("value = {:n}", 4.2); 3392 ``` 3393 3394 prints \"value = 4,2\". 3395 3396- Added an experimental Grisu floating-point formatting algorithm 3397 implementation (disabled by default). To enable it compile with the 3398 `FMT_USE_GRISU` macro defined to 1: 3399 3400 ```c++ 3401 #define FMT_USE_GRISU 1 3402 #include <fmt/format.h> 3403 3404 auto s = fmt::format("{}", 4.2); // formats 4.2 using Grisu 3405 ``` 3406 3407 With Grisu enabled, {fmt} is 13x faster than `std::ostringstream` 3408 (libc++) and 10x faster than `sprintf` on 3409 [dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark) ([full 3410 results](https://fmt.dev/unknown_mac64_clang10.0.html)): 3411 3412  3413 3414- Separated formatting and parsing contexts for consistency with 3415 [C++20 std::format](http://eel.is/c++draft/format), removing the 3416 undocumented `basic_format_context::parse_context()` function. 3417 3418- Added [oss-fuzz](https://github.com/google/oss-fuzz) support 3419 (https://github.com/fmtlib/fmt/pull/1199). Thanks @pauldreik. 3420 3421- `formatter` specializations now always take precedence over 3422 `operator<<` (https://github.com/fmtlib/fmt/issues/952): 3423 3424 ```c++ 3425 #include <iostream> 3426 #include <fmt/ostream.h> 3427 3428 struct S {}; 3429 3430 std::ostream& operator<<(std::ostream& os, S) { 3431 return os << 1; 3432 } 3433 3434 template <> 3435 struct fmt::formatter<S> : fmt::formatter<int> { 3436 auto format(S, format_context& ctx) { 3437 return formatter<int>::format(2, ctx); 3438 } 3439 }; 3440 3441 int main() { 3442 std::cout << S() << "\n"; // prints 1 using operator<< 3443 fmt::print("{}\n", S()); // prints 2 using formatter 3444 } 3445 ``` 3446 3447- Introduced the experimental `fmt::compile` function that does format 3448 string compilation 3449 (https://github.com/fmtlib/fmt/issues/618, 3450 https://github.com/fmtlib/fmt/issues/1169, 3451 https://github.com/fmtlib/fmt/pull/1171): 3452 3453 ```c++ 3454 #include <fmt/compile.h> 3455 3456 auto f = fmt::compile<int>("{}"); 3457 std::string s = fmt::format(f, 42); // can be called multiple times to 3458 // format different values 3459 // s == "42" 3460 ``` 3461 3462 It moves the cost of parsing a format string outside of the format 3463 function which can be beneficial when identically formatting many 3464 objects of the same types. Thanks @stryku. 3465 3466- Added experimental `%` format specifier that formats floating-point 3467 values as percentages 3468 (https://github.com/fmtlib/fmt/pull/1060, 3469 https://github.com/fmtlib/fmt/pull/1069, 3470 https://github.com/fmtlib/fmt/pull/1071): 3471 3472 ```c++ 3473 auto s = fmt::format("{:.1%}", 0.42); // s == "42.0%" 3474 ``` 3475 3476 Thanks @gawain-bolton. 3477 3478- Implemented precision for floating-point durations 3479 (https://github.com/fmtlib/fmt/issues/1004, 3480 https://github.com/fmtlib/fmt/pull/1012): 3481 3482 ```c++ 3483 auto s = fmt::format("{:.1}", std::chrono::duration<double>(1.234)); 3484 // s == 1.2s 3485 ``` 3486 3487 Thanks @DanielaE. 3488 3489- Implemented `chrono` format specifiers `%Q` and `%q` that give the 3490 value and the unit respectively 3491 (https://github.com/fmtlib/fmt/pull/1019): 3492 3493 ```c++ 3494 auto value = fmt::format("{:%Q}", 42s); // value == "42" 3495 auto unit = fmt::format("{:%q}", 42s); // unit == "s" 3496 ``` 3497 3498 Thanks @DanielaE. 3499 3500- Fixed handling of dynamic width in chrono formatter: 3501 3502 ```c++ 3503 auto s = fmt::format("{0:{1}%H:%M:%S}", std::chrono::seconds(12345), 12); 3504 // ^ width argument index ^ width 3505 // s == "03:25:45 " 3506 ``` 3507 3508 Thanks Howard Hinnant. 3509 3510- Removed deprecated `fmt/time.h`. Use `fmt/chrono.h` instead. 3511 3512- Added `fmt::format` and `fmt::vformat` overloads that take 3513 `text_style` (https://github.com/fmtlib/fmt/issues/993, 3514 https://github.com/fmtlib/fmt/pull/994): 3515 3516 ```c++ 3517 #include <fmt/color.h> 3518 3519 std::string message = fmt::format(fmt::emphasis::bold | fg(fmt::color::red), 3520 "The answer is {}.", 42); 3521 ``` 3522 3523 Thanks @Naios. 3524 3525- Removed the deprecated color API (`print_colored`). Use the new API, 3526 namely `print` overloads that take `text_style` instead. 3527 3528- Made `std::unique_ptr` and `std::shared_ptr` formattable as pointers 3529 via `fmt::ptr` (https://github.com/fmtlib/fmt/pull/1121): 3530 3531 ```c++ 3532 std::unique_ptr<int> p = ...; 3533 fmt::print("{}", fmt::ptr(p)); // prints p as a pointer 3534 ``` 3535 3536 Thanks @sighingnow. 3537 3538- Made `print` and `vprint` report I/O errors 3539 (https://github.com/fmtlib/fmt/issues/1098, 3540 https://github.com/fmtlib/fmt/pull/1099). Thanks @BillyDonahue. 3541 3542- Marked deprecated APIs with the `[[deprecated]]` attribute and 3543 removed internal uses of deprecated APIs 3544 (https://github.com/fmtlib/fmt/pull/1022). Thanks @eliaskosunen. 3545 3546- Modernized the codebase using more C++11 features and removing 3547 workarounds. Most importantly, `buffer_context` is now an alias 3548 template, so use `buffer_context<T>` instead of 3549 `buffer_context<T>::type`. These features require GCC 4.8 or later. 3550 3551- `formatter` specializations now always take precedence over implicit 3552 conversions to `int` and the undocumented `convert_to_int` trait is 3553 now deprecated. 3554 3555- Moved the undocumented `basic_writer`, `writer`, and `wwriter` types 3556 to the `internal` namespace. 3557 3558- Removed deprecated `basic_format_context::begin()`. Use `out()` 3559 instead. 3560 3561- Disallowed passing the result of `join` as an lvalue to prevent 3562 misuse. 3563 3564- Refactored the undocumented structs that represent parsed format 3565 specifiers to simplify the API and allow multibyte fill. 3566 3567- Moved SFINAE to template parameters to reduce symbol sizes. 3568 3569- Switched to `fputws` for writing wide strings so that it\'s no 3570 longer required to call `_setmode` on Windows 3571 (https://github.com/fmtlib/fmt/issues/1229, 3572 https://github.com/fmtlib/fmt/pull/1243). Thanks @jackoalan. 3573 3574- Improved literal-based API 3575 (https://github.com/fmtlib/fmt/pull/1254). Thanks @sylveon. 3576 3577- Added support for exotic platforms without `uintptr_t` such as IBM i 3578 (AS/400) which has 128-bit pointers and only 64-bit integers 3579 (https://github.com/fmtlib/fmt/issues/1059). 3580 3581- Added [Sublime Text syntax highlighting config]( 3582 https://github.com/fmtlib/fmt/blob/master/support/C%2B%2B.sublime-syntax) 3583 (https://github.com/fmtlib/fmt/issues/1037). Thanks @Kronuz. 3584 3585- Added the `FMT_ENFORCE_COMPILE_STRING` macro to enforce the use of 3586 compile-time format strings 3587 (https://github.com/fmtlib/fmt/pull/1231). Thanks @jackoalan. 3588 3589- Stopped setting `CMAKE_BUILD_TYPE` if {fmt} is a subproject 3590 (https://github.com/fmtlib/fmt/issues/1081). 3591 3592- Various build improvements 3593 (https://github.com/fmtlib/fmt/pull/1039, 3594 https://github.com/fmtlib/fmt/pull/1078, 3595 https://github.com/fmtlib/fmt/pull/1091, 3596 https://github.com/fmtlib/fmt/pull/1103, 3597 https://github.com/fmtlib/fmt/pull/1177). 3598 Thanks @luncliff, @jasonszang, @olafhering, @Lecetem and @pauldreik. 3599 3600- Improved documentation 3601 (https://github.com/fmtlib/fmt/issues/1049, 3602 https://github.com/fmtlib/fmt/pull/1051, 3603 https://github.com/fmtlib/fmt/pull/1083, 3604 https://github.com/fmtlib/fmt/pull/1113, 3605 https://github.com/fmtlib/fmt/pull/1114, 3606 https://github.com/fmtlib/fmt/issues/1146, 3607 https://github.com/fmtlib/fmt/issues/1180, 3608 https://github.com/fmtlib/fmt/pull/1250, 3609 https://github.com/fmtlib/fmt/pull/1252, 3610 https://github.com/fmtlib/fmt/pull/1265). 3611 Thanks @mikelui, @foonathan, @BillyDonahue, @jwakely, @kaisbe and 3612 @sdebionne. 3613 3614- Fixed ambiguous formatter specialization in `fmt/ranges.h` 3615 (https://github.com/fmtlib/fmt/issues/1123). 3616 3617- Fixed formatting of a non-empty `std::filesystem::path` which is an 3618 infinitely deep range of its components 3619 (https://github.com/fmtlib/fmt/issues/1268). 3620 3621- Fixed handling of general output iterators when formatting 3622 characters (https://github.com/fmtlib/fmt/issues/1056, 3623 https://github.com/fmtlib/fmt/pull/1058). Thanks @abolz. 3624 3625- Fixed handling of output iterators in `formatter` specialization for 3626 ranges (https://github.com/fmtlib/fmt/issues/1064). 3627 3628- Fixed handling of exotic character types 3629 (https://github.com/fmtlib/fmt/issues/1188). 3630 3631- Made chrono formatting work with exceptions disabled 3632 (https://github.com/fmtlib/fmt/issues/1062). 3633 3634- Fixed DLL visibility issues 3635 (https://github.com/fmtlib/fmt/pull/1134, 3636 https://github.com/fmtlib/fmt/pull/1147). Thanks @denchat. 3637 3638- Disabled the use of UDL template extension on GCC 9 3639 (https://github.com/fmtlib/fmt/issues/1148). 3640 3641- Removed misplaced `format` compile-time checks from `printf` 3642 (https://github.com/fmtlib/fmt/issues/1173). 3643 3644- Fixed issues in the experimental floating-point formatter 3645 (https://github.com/fmtlib/fmt/issues/1072, 3646 https://github.com/fmtlib/fmt/issues/1129, 3647 https://github.com/fmtlib/fmt/issues/1153, 3648 https://github.com/fmtlib/fmt/pull/1155, 3649 https://github.com/fmtlib/fmt/issues/1210, 3650 https://github.com/fmtlib/fmt/issues/1222). Thanks @alabuzhev. 3651 3652- Fixed bugs discovered by fuzzing or during fuzzing integration 3653 (https://github.com/fmtlib/fmt/issues/1124, 3654 https://github.com/fmtlib/fmt/issues/1127, 3655 https://github.com/fmtlib/fmt/issues/1132, 3656 https://github.com/fmtlib/fmt/pull/1135, 3657 https://github.com/fmtlib/fmt/issues/1136, 3658 https://github.com/fmtlib/fmt/issues/1141, 3659 https://github.com/fmtlib/fmt/issues/1142, 3660 https://github.com/fmtlib/fmt/issues/1178, 3661 https://github.com/fmtlib/fmt/issues/1179, 3662 https://github.com/fmtlib/fmt/issues/1194). Thanks @pauldreik. 3663 3664- Fixed building tests on FreeBSD and Hurd 3665 (https://github.com/fmtlib/fmt/issues/1043). Thanks @jackyf. 3666 3667- Fixed various warnings and compilation issues 3668 (https://github.com/fmtlib/fmt/pull/998, 3669 https://github.com/fmtlib/fmt/pull/1006, 3670 https://github.com/fmtlib/fmt/issues/1008, 3671 https://github.com/fmtlib/fmt/issues/1011, 3672 https://github.com/fmtlib/fmt/issues/1025, 3673 https://github.com/fmtlib/fmt/pull/1027, 3674 https://github.com/fmtlib/fmt/pull/1028, 3675 https://github.com/fmtlib/fmt/pull/1029, 3676 https://github.com/fmtlib/fmt/pull/1030, 3677 https://github.com/fmtlib/fmt/pull/1031, 3678 https://github.com/fmtlib/fmt/pull/1054, 3679 https://github.com/fmtlib/fmt/issues/1063, 3680 https://github.com/fmtlib/fmt/pull/1068, 3681 https://github.com/fmtlib/fmt/pull/1074, 3682 https://github.com/fmtlib/fmt/pull/1075, 3683 https://github.com/fmtlib/fmt/pull/1079, 3684 https://github.com/fmtlib/fmt/pull/1086, 3685 https://github.com/fmtlib/fmt/issues/1088, 3686 https://github.com/fmtlib/fmt/pull/1089, 3687 https://github.com/fmtlib/fmt/pull/1094, 3688 https://github.com/fmtlib/fmt/issues/1101, 3689 https://github.com/fmtlib/fmt/pull/1102, 3690 https://github.com/fmtlib/fmt/issues/1105, 3691 https://github.com/fmtlib/fmt/pull/1107, 3692 https://github.com/fmtlib/fmt/issues/1115, 3693 https://github.com/fmtlib/fmt/issues/1117, 3694 https://github.com/fmtlib/fmt/issues/1118, 3695 https://github.com/fmtlib/fmt/issues/1120, 3696 https://github.com/fmtlib/fmt/issues/1123, 3697 https://github.com/fmtlib/fmt/pull/1139, 3698 https://github.com/fmtlib/fmt/issues/1140, 3699 https://github.com/fmtlib/fmt/issues/1143, 3700 https://github.com/fmtlib/fmt/pull/1144, 3701 https://github.com/fmtlib/fmt/pull/1150, 3702 https://github.com/fmtlib/fmt/pull/1151, 3703 https://github.com/fmtlib/fmt/issues/1152, 3704 https://github.com/fmtlib/fmt/issues/1154, 3705 https://github.com/fmtlib/fmt/issues/1156, 3706 https://github.com/fmtlib/fmt/pull/1159, 3707 https://github.com/fmtlib/fmt/issues/1175, 3708 https://github.com/fmtlib/fmt/issues/1181, 3709 https://github.com/fmtlib/fmt/issues/1186, 3710 https://github.com/fmtlib/fmt/pull/1187, 3711 https://github.com/fmtlib/fmt/pull/1191, 3712 https://github.com/fmtlib/fmt/issues/1197, 3713 https://github.com/fmtlib/fmt/issues/1200, 3714 https://github.com/fmtlib/fmt/issues/1203, 3715 https://github.com/fmtlib/fmt/issues/1205, 3716 https://github.com/fmtlib/fmt/pull/1206, 3717 https://github.com/fmtlib/fmt/issues/1213, 3718 https://github.com/fmtlib/fmt/issues/1214, 3719 https://github.com/fmtlib/fmt/pull/1217, 3720 https://github.com/fmtlib/fmt/issues/1228, 3721 https://github.com/fmtlib/fmt/pull/1230, 3722 https://github.com/fmtlib/fmt/issues/1232, 3723 https://github.com/fmtlib/fmt/pull/1235, 3724 https://github.com/fmtlib/fmt/pull/1236, 3725 https://github.com/fmtlib/fmt/issues/1240). 3726 Thanks @DanielaE, @mwinterb, @eliaskosunen, @morinmorin, @ricco19, 3727 @waywardmonkeys, @chronoxor, @remyabel, @pauldreik, @gsjaardema, @rcane, 3728 @mocabe, @denchat, @cjdb, @HazardyKnusperkeks, @vedranmiletic, @jackoalan, 3729 @DaanDeMeyer and @starkmapper. 3730 3731# 5.3.0 - 2018-12-28 3732 3733- Introduced experimental chrono formatting support: 3734 3735 ```c++ 3736 #include <fmt/chrono.h> 3737 3738 int main() { 3739 using namespace std::literals::chrono_literals; 3740 fmt::print("Default format: {} {}\n", 42s, 100ms); 3741 fmt::print("strftime-like format: {:%H:%M:%S}\n", 3h + 15min + 30s); 3742 } 3743 ``` 3744 3745 prints: 3746 3747 Default format: 42s 100ms 3748 strftime-like format: 03:15:30 3749 3750- Added experimental support for emphasis (bold, italic, underline, 3751 strikethrough), colored output to a file stream, and improved 3752 colored formatting API 3753 (https://github.com/fmtlib/fmt/pull/961, 3754 https://github.com/fmtlib/fmt/pull/967, 3755 https://github.com/fmtlib/fmt/pull/973): 3756 3757 ```c++ 3758 #include <fmt/color.h> 3759 3760 int main() { 3761 print(fg(fmt::color::crimson) | fmt::emphasis::bold, 3762 "Hello, {}!\n", "world"); 3763 print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) | 3764 fmt::emphasis::underline, "Hello, {}!\n", "мир"); 3765 print(fg(fmt::color::steel_blue) | fmt::emphasis::italic, 3766 "Hello, {}!\n", "世界"); 3767 } 3768 ``` 3769 3770 prints the following on modern terminals with RGB color support: 3771 3772  3773 3774 Thanks @Rakete1111. 3775 3776- Added support for 4-bit terminal colors 3777 (https://github.com/fmtlib/fmt/issues/968, 3778 https://github.com/fmtlib/fmt/pull/974) 3779 3780 ```c++ 3781 #include <fmt/color.h> 3782 3783 int main() { 3784 print(fg(fmt::terminal_color::red), "stop\n"); 3785 } 3786 ``` 3787 3788 Note that these colors vary by terminal: 3789 3790  3791 3792 Thanks @Rakete1111. 3793 3794- Parameterized formatting functions on the type of the format string 3795 (https://github.com/fmtlib/fmt/issues/880, 3796 https://github.com/fmtlib/fmt/pull/881, 3797 https://github.com/fmtlib/fmt/pull/883, 3798 https://github.com/fmtlib/fmt/pull/885, 3799 https://github.com/fmtlib/fmt/pull/897, 3800 https://github.com/fmtlib/fmt/issues/920). Any object of 3801 type `S` that has an overloaded `to_string_view(const S&)` returning 3802 `fmt::string_view` can be used as a format string: 3803 3804 ```c++ 3805 namespace my_ns { 3806 inline string_view to_string_view(const my_string& s) { 3807 return {s.data(), s.length()}; 3808 } 3809 } 3810 3811 std::string message = fmt::format(my_string("The answer is {}."), 42); 3812 ``` 3813 3814 Thanks @DanielaE. 3815 3816- Made `std::string_view` work as a format string 3817 (https://github.com/fmtlib/fmt/pull/898): 3818 3819 ```c++ 3820 auto message = fmt::format(std::string_view("The answer is {}."), 42); 3821 ``` 3822 3823 Thanks @DanielaE. 3824 3825- Added wide string support to compile-time format string checks 3826 (https://github.com/fmtlib/fmt/pull/924): 3827 3828 ```c++ 3829 print(fmt(L"{:f}"), 42); // compile-time error: invalid type specifier 3830 ``` 3831 3832 Thanks @XZiar. 3833 3834- Made colored print functions work with wide strings 3835 (https://github.com/fmtlib/fmt/pull/867): 3836 3837 ```c++ 3838 #include <fmt/color.h> 3839 3840 int main() { 3841 print(fg(fmt::color::red), L"{}\n", 42); 3842 } 3843 ``` 3844 3845 Thanks @DanielaE. 3846 3847- Introduced experimental Unicode support 3848 (https://github.com/fmtlib/fmt/issues/628, 3849 https://github.com/fmtlib/fmt/pull/891): 3850 3851 ```c++ 3852 using namespace fmt::literals; 3853 auto s = fmt::format("{:*^5}"_u, ""_u); // s == "****"_u 3854 ``` 3855 3856- Improved locale support: 3857 3858 ```c++ 3859 #include <fmt/locale.h> 3860 3861 struct numpunct : std::numpunct<char> { 3862 protected: 3863 char do_thousands_sep() const override { return '~'; } 3864 }; 3865 3866 std::locale loc; 3867 auto s = fmt::format(std::locale(loc, new numpunct()), "{:n}", 1234567); 3868 // s == "1~234~567" 3869 ``` 3870 3871- Constrained formatting functions on proper iterator types 3872 (https://github.com/fmtlib/fmt/pull/921). Thanks @DanielaE. 3873 3874- Added `make_printf_args` and `make_wprintf_args` functions 3875 (https://github.com/fmtlib/fmt/pull/934). Thanks @tnovotny. 3876 3877- Deprecated `fmt::visit`, `parse_context`, and `wparse_context`. Use 3878 `fmt::visit_format_arg`, `format_parse_context`, and 3879 `wformat_parse_context` instead. 3880 3881- Removed undocumented `basic_fixed_buffer` which has been superseded 3882 by the iterator-based API 3883 (https://github.com/fmtlib/fmt/issues/873, 3884 https://github.com/fmtlib/fmt/pull/902). Thanks @superfunc. 3885 3886- Disallowed repeated leading zeros in an argument ID: 3887 3888 ```c++ 3889 fmt::print("{000}", 42); // error 3890 ``` 3891 3892- Reintroduced support for gcc 4.4. 3893 3894- Fixed compilation on platforms with exotic `double` 3895 (https://github.com/fmtlib/fmt/issues/878). 3896 3897- Improved documentation 3898 (https://github.com/fmtlib/fmt/issues/164, 3899 https://github.com/fmtlib/fmt/issues/877, 3900 https://github.com/fmtlib/fmt/pull/901, 3901 https://github.com/fmtlib/fmt/pull/906, 3902 https://github.com/fmtlib/fmt/pull/979). 3903 Thanks @kookjr, @DarkDimius and @HecticSerenity. 3904 3905- Added pkgconfig support which makes it easier to consume the library 3906 from meson and other build systems 3907 (https://github.com/fmtlib/fmt/pull/916). Thanks @colemickens. 3908 3909- Various build improvements 3910 (https://github.com/fmtlib/fmt/pull/909, 3911 https://github.com/fmtlib/fmt/pull/926, 3912 https://github.com/fmtlib/fmt/pull/937, 3913 https://github.com/fmtlib/fmt/pull/953, 3914 https://github.com/fmtlib/fmt/pull/959). 3915 Thanks @tchaikov, @luncliff, @AndreasSchoenle, @hotwatermorning and @Zefz. 3916 3917- Improved `string_view` construction performance 3918 (https://github.com/fmtlib/fmt/pull/914). Thanks @gabime. 3919 3920- Fixed non-matching char types 3921 (https://github.com/fmtlib/fmt/pull/895). Thanks @DanielaE. 3922 3923- Fixed `format_to_n` with `std::back_insert_iterator` 3924 (https://github.com/fmtlib/fmt/pull/913). Thanks @DanielaE. 3925 3926- Fixed locale-dependent formatting 3927 (https://github.com/fmtlib/fmt/issues/905). 3928 3929- Fixed various compiler warnings and errors 3930 (https://github.com/fmtlib/fmt/pull/882, 3931 https://github.com/fmtlib/fmt/pull/886, 3932 https://github.com/fmtlib/fmt/pull/933, 3933 https://github.com/fmtlib/fmt/pull/941, 3934 https://github.com/fmtlib/fmt/issues/931, 3935 https://github.com/fmtlib/fmt/pull/943, 3936 https://github.com/fmtlib/fmt/pull/954, 3937 https://github.com/fmtlib/fmt/pull/956, 3938 https://github.com/fmtlib/fmt/pull/962, 3939 https://github.com/fmtlib/fmt/issues/965, 3940 https://github.com/fmtlib/fmt/issues/977, 3941 https://github.com/fmtlib/fmt/pull/983, 3942 https://github.com/fmtlib/fmt/pull/989). 3943 Thanks @Luthaf, @stevenhoving, @christinaa, @lgritz, @DanielaE, 3944 @0x8000-0000 and @liuping1997. 3945 3946# 5.2.1 - 2018-09-21 3947 3948- Fixed `visit` lookup issues on gcc 7 & 8 3949 (https://github.com/fmtlib/fmt/pull/870). Thanks @medithe. 3950- Fixed linkage errors on older gcc. 3951- Prevented `fmt/range.h` from specializing `fmt::basic_string_view` 3952 (https://github.com/fmtlib/fmt/issues/865, 3953 https://github.com/fmtlib/fmt/pull/868). Thanks @hhggit. 3954- Improved error message when formatting unknown types 3955 (https://github.com/fmtlib/fmt/pull/872). Thanks @foonathan. 3956- Disabled templated user-defined literals when compiled under nvcc 3957 (https://github.com/fmtlib/fmt/pull/875). Thanks @CandyGumdrop. 3958- Fixed `format_to` formatting to `wmemory_buffer` 3959 (https://github.com/fmtlib/fmt/issues/874). 3960 3961# 5.2.0 - 2018-09-13 3962 3963- Optimized format string parsing and argument processing which 3964 resulted in up to 5x speed up on long format strings and significant 3965 performance boost on various benchmarks. For example, version 5.2 is 3966 2.22x faster than 5.1 on decimal integer formatting with `format_to` 3967 (macOS, clang-902.0.39.2): 3968 3969 | Method | Time, s | Speedup | 3970 | -------------------------- | --------------: | ------: | 3971 | fmt::format 5.1 | 0.58 | | 3972 | fmt::format 5.2 | 0.35 | 1.66x | 3973 | fmt::format_to 5.1 | 0.51 | | 3974 | fmt::format_to 5.2 | 0.23 | 2.22x | 3975 | sprintf | 0.71 | | 3976 | std::to_string | 1.01 | | 3977 | std::stringstream | 1.73 | | 3978 3979- Changed the `fmt` macro from opt-out to opt-in to prevent name 3980 collisions. To enable it define the `FMT_STRING_ALIAS` macro to 1 3981 before including `fmt/format.h`: 3982 3983 ```c++ 3984 #define FMT_STRING_ALIAS 1 3985 #include <fmt/format.h> 3986 std::string answer = format(fmt("{}"), 42); 3987 ``` 3988 3989- Added compile-time format string checks to `format_to` overload that 3990 takes `fmt::memory_buffer` 3991 (https://github.com/fmtlib/fmt/issues/783): 3992 3993 ```c++ 3994 fmt::memory_buffer buf; 3995 // Compile-time error: invalid type specifier. 3996 fmt::format_to(buf, fmt("{:d}"), "foo"); 3997 ``` 3998 3999- Moved experimental color support to `fmt/color.h` and enabled the 4000 new API by default. The old API can be enabled by defining the 4001 `FMT_DEPRECATED_COLORS` macro. 4002 4003- Added formatting support for types explicitly convertible to 4004 `fmt::string_view`: 4005 4006 ```c++ 4007 struct foo { 4008 explicit operator fmt::string_view() const { return "foo"; } 4009 }; 4010 auto s = format("{}", foo()); 4011 ``` 4012 4013 In particular, this makes formatting function work with 4014 `folly::StringPiece`. 4015 4016- Implemented preliminary support for `char*_t` by replacing the 4017 `format` function overloads with a single function template 4018 parameterized on the string type. 4019 4020- Added support for dynamic argument lists 4021 (https://github.com/fmtlib/fmt/issues/814, 4022 https://github.com/fmtlib/fmt/pull/819). Thanks @MikePopoloski. 4023 4024- Reduced executable size overhead for embedded targets using newlib 4025 nano by making locale dependency optional 4026 (https://github.com/fmtlib/fmt/pull/839). Thanks @teajay-fr. 4027 4028- Keep `noexcept` specifier when exceptions are disabled 4029 (https://github.com/fmtlib/fmt/issues/801, 4030 https://github.com/fmtlib/fmt/pull/810). Thanks @qis. 4031 4032- Fixed formatting of user-defined types providing `operator<<` with 4033 `format_to_n` (https://github.com/fmtlib/fmt/pull/806). 4034 Thanks @mkurdej. 4035 4036- Fixed dynamic linkage of new symbols 4037 (https://github.com/fmtlib/fmt/issues/808). 4038 4039- Fixed global initialization issue 4040 (https://github.com/fmtlib/fmt/issues/807): 4041 4042 ```c++ 4043 // This works on compilers with constexpr support. 4044 static const std::string answer = fmt::format("{}", 42); 4045 ``` 4046 4047- Fixed various compiler warnings and errors 4048 (https://github.com/fmtlib/fmt/pull/804, 4049 https://github.com/fmtlib/fmt/issues/809, 4050 https://github.com/fmtlib/fmt/pull/811, 4051 https://github.com/fmtlib/fmt/issues/822, 4052 https://github.com/fmtlib/fmt/pull/827, 4053 https://github.com/fmtlib/fmt/issues/830, 4054 https://github.com/fmtlib/fmt/pull/838, 4055 https://github.com/fmtlib/fmt/issues/843, 4056 https://github.com/fmtlib/fmt/pull/844, 4057 https://github.com/fmtlib/fmt/issues/851, 4058 https://github.com/fmtlib/fmt/pull/852, 4059 https://github.com/fmtlib/fmt/pull/854). 4060 Thanks @henryiii, @medithe, and @eliasdaler. 4061 4062# 5.1.0 - 2018-07-05 4063 4064- Added experimental support for RGB color output enabled with the 4065 `FMT_EXTENDED_COLORS` macro: 4066 4067 ```c++ 4068 #define FMT_EXTENDED_COLORS 4069 #define FMT_HEADER_ONLY // or compile fmt with FMT_EXTENDED_COLORS defined 4070 #include <fmt/format.h> 4071 4072 fmt::print(fmt::color::steel_blue, "Some beautiful text"); 4073 ``` 4074 4075 The old API (the `print_colored` and `vprint_colored` functions and 4076 the `color` enum) is now deprecated. 4077 (https://github.com/fmtlib/fmt/issues/762 4078 https://github.com/fmtlib/fmt/pull/767). thanks @Remotion. 4079 4080- Added quotes to strings in ranges and tuples 4081 (https://github.com/fmtlib/fmt/pull/766). Thanks @Remotion. 4082 4083- Made `format_to` work with `basic_memory_buffer` 4084 (https://github.com/fmtlib/fmt/issues/776). 4085 4086- Added `vformat_to_n` and `wchar_t` overload of `format_to_n` 4087 (https://github.com/fmtlib/fmt/issues/764, 4088 https://github.com/fmtlib/fmt/issues/769). 4089 4090- Made `is_range` and `is_tuple_like` part of public (experimental) 4091 API to allow specialization for user-defined types 4092 (https://github.com/fmtlib/fmt/issues/751, 4093 https://github.com/fmtlib/fmt/pull/759). Thanks @drrlvn. 4094 4095- Added more compilers to continuous integration and increased 4096 `FMT_PEDANTIC` warning levels 4097 (https://github.com/fmtlib/fmt/pull/736). Thanks @eliaskosunen. 4098 4099- Fixed compilation with MSVC 2013. 4100 4101- Fixed handling of user-defined types in `format_to` 4102 (https://github.com/fmtlib/fmt/issues/793). 4103 4104- Forced linking of inline `vformat` functions into the library 4105 (https://github.com/fmtlib/fmt/issues/795). 4106 4107- Fixed incorrect call to on_align in `'{:}='` 4108 (https://github.com/fmtlib/fmt/issues/750). 4109 4110- Fixed floating-point formatting to a non-back_insert_iterator with 4111 sign & numeric alignment specified 4112 (https://github.com/fmtlib/fmt/issues/756). 4113 4114- Fixed formatting to an array with `format_to_n` 4115 (https://github.com/fmtlib/fmt/issues/778). 4116 4117- Fixed formatting of more than 15 named arguments 4118 (https://github.com/fmtlib/fmt/issues/754). 4119 4120- Fixed handling of compile-time strings when including 4121 `fmt/ostream.h`. (https://github.com/fmtlib/fmt/issues/768). 4122 4123- Fixed various compiler warnings and errors 4124 (https://github.com/fmtlib/fmt/issues/742, 4125 https://github.com/fmtlib/fmt/issues/748, 4126 https://github.com/fmtlib/fmt/issues/752, 4127 https://github.com/fmtlib/fmt/issues/770, 4128 https://github.com/fmtlib/fmt/pull/775, 4129 https://github.com/fmtlib/fmt/issues/779, 4130 https://github.com/fmtlib/fmt/pull/780, 4131 https://github.com/fmtlib/fmt/pull/790, 4132 https://github.com/fmtlib/fmt/pull/792, 4133 https://github.com/fmtlib/fmt/pull/800). 4134 Thanks @Remotion, @gabime, @foonathan, @Dark-Passenger and @0x8000-0000. 4135 4136# 5.0.0 - 2018-05-21 4137 4138- Added a requirement for partial C++11 support, most importantly 4139 variadic templates and type traits, and dropped `FMT_VARIADIC_*` 4140 emulation macros. Variadic templates are available since GCC 4.4, 4141 Clang 2.9 and MSVC 18.0 (2013). For older compilers use {fmt} 4142 [version 4.x](https://github.com/fmtlib/fmt/releases/tag/4.1.0) 4143 which continues to be maintained and works with C++98 compilers. 4144 4145- Renamed symbols to follow standard C++ naming conventions and 4146 proposed a subset of the library for standardization in [P0645R2 4147 Text Formatting](https://wg21.link/P0645). 4148 4149- Implemented `constexpr` parsing of format strings and [compile-time 4150 format string 4151 checks](https://fmt.dev/latest/api.html#compile-time-format-string-checks). 4152 For example 4153 4154 ```c++ 4155 #include <fmt/format.h> 4156 4157 std::string s = format(fmt("{:d}"), "foo"); 4158 ``` 4159 4160 gives a compile-time error because `d` is an invalid specifier for 4161 strings ([godbolt](https://godbolt.org/g/rnCy9Q)): 4162 4163 ... 4164 <source>:4:19: note: in instantiation of function template specialization 'fmt::v5::format<S, char [4]>' requested here 4165 std::string s = format(fmt("{:d}"), "foo"); 4166 ^ 4167 format.h:1337:13: note: non-constexpr function 'on_error' cannot be used in a constant expression 4168 handler.on_error("invalid type specifier"); 4169 4170 Compile-time checks require relaxed `constexpr` (C++14 feature) 4171 support. If the latter is not available, checks will be performed at 4172 runtime. 4173 4174- Separated format string parsing and formatting in the extension API 4175 to enable compile-time format string processing. For example 4176 4177 ```c++ 4178 struct Answer {}; 4179 4180 namespace fmt { 4181 template <> 4182 struct formatter<Answer> { 4183 constexpr auto parse(parse_context& ctx) { 4184 auto it = ctx.begin(); 4185 spec = *it; 4186 if (spec != 'd' && spec != 's') 4187 throw format_error("invalid specifier"); 4188 return ++it; 4189 } 4190 4191 template <typename FormatContext> 4192 auto format(Answer, FormatContext& ctx) { 4193 return spec == 's' ? 4194 format_to(ctx.begin(), "{}", "fourty-two") : 4195 format_to(ctx.begin(), "{}", 42); 4196 } 4197 4198 char spec = 0; 4199 }; 4200 } 4201 4202 std::string s = format(fmt("{:x}"), Answer()); 4203 ``` 4204 4205 gives a compile-time error due to invalid format specifier 4206 ([godbolt](https://godbolt.org/g/2jQ1Dv)): 4207 4208 ... 4209 <source>:12:45: error: expression '<throw-expression>' is not a constant expression 4210 throw format_error("invalid specifier"); 4211 4212- Added [iterator 4213 support](https://fmt.dev/latest/api.html#output-iterator-support): 4214 4215 ```c++ 4216 #include <vector> 4217 #include <fmt/format.h> 4218 4219 std::vector<char> out; 4220 fmt::format_to(std::back_inserter(out), "{}", 42); 4221 ``` 4222 4223- Added the 4224 [format_to_n](https://fmt.dev/latest/api.html#_CPPv2N3fmt11format_to_nE8OutputItNSt6size_tE11string_viewDpRK4Args) 4225 function that restricts the output to the specified number of 4226 characters (https://github.com/fmtlib/fmt/issues/298): 4227 4228 ```c++ 4229 char out[4]; 4230 fmt::format_to_n(out, sizeof(out), "{}", 12345); 4231 // out == "1234" (without terminating '\0') 4232 ``` 4233 4234- Added the [formatted_size]( 4235 https://fmt.dev/latest/api.html#_CPPv2N3fmt14formatted_sizeE11string_viewDpRK4Args) 4236 function for computing the output size: 4237 4238 ```c++ 4239 #include <fmt/format.h> 4240 4241 auto size = fmt::formatted_size("{}", 12345); // size == 5 4242 ``` 4243 4244- Improved compile times by reducing dependencies on standard headers 4245 and providing a lightweight [core 4246 API](https://fmt.dev/latest/api.html#core-api): 4247 4248 ```c++ 4249 #include <fmt/core.h> 4250 4251 fmt::print("The answer is {}.", 42); 4252 ``` 4253 4254 See [Compile time and code 4255 bloat](https://github.com/fmtlib/fmt#compile-time-and-code-bloat). 4256 4257- Added the [make_format_args]( 4258 https://fmt.dev/latest/api.html#_CPPv2N3fmt16make_format_argsEDpRK4Args) 4259 function for capturing formatting arguments: 4260 4261 ```c++ 4262 // Prints formatted error message. 4263 void vreport_error(const char *format, fmt::format_args args) { 4264 fmt::print("Error: "); 4265 fmt::vprint(format, args); 4266 } 4267 template <typename... Args> 4268 void report_error(const char *format, const Args & ... args) { 4269 vreport_error(format, fmt::make_format_args(args...)); 4270 } 4271 ``` 4272 4273- Added the `make_printf_args` function for capturing `printf` 4274 arguments (https://github.com/fmtlib/fmt/issues/687, 4275 https://github.com/fmtlib/fmt/pull/694). Thanks @Kronuz. 4276 4277- Added prefix `v` to non-variadic functions taking `format_args` to 4278 distinguish them from variadic ones: 4279 4280 ```c++ 4281 std::string vformat(string_view format_str, format_args args); 4282 4283 template <typename... Args> 4284 std::string format(string_view format_str, const Args & ... args); 4285 ``` 4286 4287- Added experimental support for formatting ranges, containers and 4288 tuple-like types in `fmt/ranges.h` 4289 (https://github.com/fmtlib/fmt/pull/735): 4290 4291 ```c++ 4292 #include <fmt/ranges.h> 4293 4294 std::vector<int> v = {1, 2, 3}; 4295 fmt::print("{}", v); // prints {1, 2, 3} 4296 ``` 4297 4298 Thanks @Remotion. 4299 4300- Implemented `wchar_t` date and time formatting 4301 (https://github.com/fmtlib/fmt/pull/712): 4302 4303 ```c++ 4304 #include <fmt/time.h> 4305 4306 std::time_t t = std::time(nullptr); 4307 auto s = fmt::format(L"The date is {:%Y-%m-%d}.", *std::localtime(&t)); 4308 ``` 4309 4310 Thanks @DanielaE. 4311 4312- Provided more wide string overloads 4313 (https://github.com/fmtlib/fmt/pull/724). Thanks @DanielaE. 4314 4315- Switched from a custom null-terminated string view class to 4316 `string_view` in the format API and provided `fmt::string_view` 4317 which implements a subset of `std::string_view` API for pre-C++17 4318 systems. 4319 4320- Added support for `std::experimental::string_view` 4321 (https://github.com/fmtlib/fmt/pull/607): 4322 4323 ```c++ 4324 #include <fmt/core.h> 4325 #include <experimental/string_view> 4326 4327 fmt::print("{}", std::experimental::string_view("foo")); 4328 ``` 4329 4330 Thanks @virgiliofornazin. 4331 4332- Allowed mixing named and automatic arguments: 4333 4334 ```c++ 4335 fmt::format("{} {two}", 1, fmt::arg("two", 2)); 4336 ``` 4337 4338- Removed the write API in favor of the [format 4339 API](https://fmt.dev/latest/api.html#format-api) with compile-time 4340 handling of format strings. 4341 4342- Disallowed formatting of multibyte strings into a wide character 4343 target (https://github.com/fmtlib/fmt/pull/606). 4344 4345- Improved documentation 4346 (https://github.com/fmtlib/fmt/pull/515, 4347 https://github.com/fmtlib/fmt/issues/614, 4348 https://github.com/fmtlib/fmt/pull/617, 4349 https://github.com/fmtlib/fmt/pull/661, 4350 https://github.com/fmtlib/fmt/pull/680). 4351 Thanks @ibell, @mihaitodor and @johnthagen. 4352 4353- Implemented more efficient handling of large number of format 4354 arguments. 4355 4356- Introduced an inline namespace for symbol versioning. 4357 4358- Added debug postfix `d` to the `fmt` library name 4359 (https://github.com/fmtlib/fmt/issues/636). 4360 4361- Removed unnecessary `fmt/` prefix in includes 4362 (https://github.com/fmtlib/fmt/pull/397). Thanks @chronoxor. 4363 4364- Moved `fmt/*.h` to `include/fmt/*.h` to prevent irrelevant files and 4365 directories appearing on the include search paths when fmt is used 4366 as a subproject and moved source files to the `src` directory. 4367 4368- Added qmake project file `support/fmt.pro` 4369 (https://github.com/fmtlib/fmt/pull/641). Thanks @cowo78. 4370 4371- Added Gradle build file `support/build.gradle` 4372 (https://github.com/fmtlib/fmt/pull/649). Thanks @luncliff. 4373 4374- Removed `FMT_CPPFORMAT` CMake option. 4375 4376- Fixed a name conflict with the macro `CHAR_WIDTH` in glibc 4377 (https://github.com/fmtlib/fmt/pull/616). Thanks @aroig. 4378 4379- Fixed handling of nested braces in `fmt::join` 4380 (https://github.com/fmtlib/fmt/issues/638). 4381 4382- Added `SOURCELINK_SUFFIX` for compatibility with Sphinx 1.5 4383 (https://github.com/fmtlib/fmt/pull/497). Thanks @ginggs. 4384 4385- Added a missing `inline` in the header-only mode 4386 (https://github.com/fmtlib/fmt/pull/626). Thanks @aroig. 4387 4388- Fixed various compiler warnings 4389 (https://github.com/fmtlib/fmt/pull/640, 4390 https://github.com/fmtlib/fmt/pull/656, 4391 https://github.com/fmtlib/fmt/pull/679, 4392 https://github.com/fmtlib/fmt/pull/681, 4393 https://github.com/fmtlib/fmt/pull/705, 4394 https://github.com/fmtlib/fmt/issues/715, 4395 https://github.com/fmtlib/fmt/pull/717, 4396 https://github.com/fmtlib/fmt/pull/720, 4397 https://github.com/fmtlib/fmt/pull/723, 4398 https://github.com/fmtlib/fmt/pull/726, 4399 https://github.com/fmtlib/fmt/pull/730, 4400 https://github.com/fmtlib/fmt/pull/739). 4401 Thanks @peterbell10, @LarsGullik, @foonathan, @eliaskosunen, 4402 @christianparpart, @DanielaE and @mwinterb. 4403 4404- Worked around an MSVC bug and fixed several warnings 4405 (https://github.com/fmtlib/fmt/pull/653). Thanks @alabuzhev. 4406 4407- Worked around GCC bug 67371 4408 (https://github.com/fmtlib/fmt/issues/682). 4409 4410- Fixed compilation with `-fno-exceptions` 4411 (https://github.com/fmtlib/fmt/pull/655). Thanks @chenxiaolong. 4412 4413- Made `constexpr remove_prefix` gcc version check tighter 4414 (https://github.com/fmtlib/fmt/issues/648). 4415 4416- Renamed internal type enum constants to prevent collision with 4417 poorly written C libraries 4418 (https://github.com/fmtlib/fmt/issues/644). 4419 4420- Added detection of `wostream operator<<` 4421 (https://github.com/fmtlib/fmt/issues/650). 4422 4423- Fixed compilation on OpenBSD 4424 (https://github.com/fmtlib/fmt/pull/660). Thanks @hubslave. 4425 4426- Fixed compilation on FreeBSD 12 4427 (https://github.com/fmtlib/fmt/pull/732). Thanks @dankm. 4428 4429- Fixed compilation when there is a mismatch between `-std` options 4430 between the library and user code 4431 (https://github.com/fmtlib/fmt/issues/664). 4432 4433- Fixed compilation with GCC 7 and `-std=c++11` 4434 (https://github.com/fmtlib/fmt/issues/734). 4435 4436- Improved generated binary code on GCC 7 and older 4437 (https://github.com/fmtlib/fmt/issues/668). 4438 4439- Fixed handling of numeric alignment with no width 4440 (https://github.com/fmtlib/fmt/issues/675). 4441 4442- Fixed handling of empty strings in UTF8/16 converters 4443 (https://github.com/fmtlib/fmt/pull/676). Thanks @vgalka-sl. 4444 4445- Fixed formatting of an empty `string_view` 4446 (https://github.com/fmtlib/fmt/issues/689). 4447 4448- Fixed detection of `string_view` on libc++ 4449 (https://github.com/fmtlib/fmt/issues/686). 4450 4451- Fixed DLL issues (https://github.com/fmtlib/fmt/pull/696). 4452 Thanks @sebkoenig. 4453 4454- Fixed compile checks for mixing narrow and wide strings 4455 (https://github.com/fmtlib/fmt/issues/690). 4456 4457- Disabled unsafe implicit conversion to `std::string` 4458 (https://github.com/fmtlib/fmt/issues/729). 4459 4460- Fixed handling of reused format specs (as in `fmt::join`) for 4461 pointers (https://github.com/fmtlib/fmt/pull/725). Thanks @mwinterb. 4462 4463- Fixed installation of `fmt/ranges.h` 4464 (https://github.com/fmtlib/fmt/pull/738). Thanks @sv1990. 4465 4466# 4.1.0 - 2017-12-20 4467 4468- Added `fmt::to_wstring()` in addition to `fmt::to_string()` 4469 (https://github.com/fmtlib/fmt/pull/559). Thanks @alabuzhev. 4470- Added support for C++17 `std::string_view` 4471 (https://github.com/fmtlib/fmt/pull/571 and 4472 https://github.com/fmtlib/fmt/pull/578). 4473 Thanks @thelostt and @mwinterb. 4474- Enabled stream exceptions to catch errors 4475 (https://github.com/fmtlib/fmt/issues/581). Thanks @crusader-mike. 4476- Allowed formatting of class hierarchies with `fmt::format_arg()` 4477 (https://github.com/fmtlib/fmt/pull/547). Thanks @rollbear. 4478- Removed limitations on character types 4479 (https://github.com/fmtlib/fmt/pull/563). Thanks @Yelnats321. 4480- Conditionally enabled use of `std::allocator_traits` 4481 (https://github.com/fmtlib/fmt/pull/583). Thanks @mwinterb. 4482- Added support for `const` variadic member function emulation with 4483 `FMT_VARIADIC_CONST` 4484 (https://github.com/fmtlib/fmt/pull/591). Thanks @ludekvodicka. 4485- Various bugfixes: bad overflow check, unsupported implicit type 4486 conversion when determining formatting function, test segfaults 4487 (https://github.com/fmtlib/fmt/issues/551), ill-formed 4488 macros (https://github.com/fmtlib/fmt/pull/542) and 4489 ambiguous overloads 4490 (https://github.com/fmtlib/fmt/issues/580). Thanks @xylosper. 4491- Prevented warnings on MSVC 4492 (https://github.com/fmtlib/fmt/pull/605, 4493 https://github.com/fmtlib/fmt/pull/602, and 4494 https://github.com/fmtlib/fmt/pull/545), clang 4495 (https://github.com/fmtlib/fmt/pull/582), GCC 4496 (https://github.com/fmtlib/fmt/issues/573), various 4497 conversion warnings (https://github.com/fmtlib/fmt/pull/609, 4498 https://github.com/fmtlib/fmt/pull/567, 4499 https://github.com/fmtlib/fmt/pull/553 and 4500 https://github.com/fmtlib/fmt/pull/553), and added 4501 `override` and `[[noreturn]]` 4502 (https://github.com/fmtlib/fmt/pull/549 and 4503 https://github.com/fmtlib/fmt/issues/555). 4504 Thanks @alabuzhev, @virgiliofornazin, @alexanderbock, @yumetodo, @VaderY, 4505 @jpcima, @thelostt and @Manu343726. 4506- Improved CMake: Used `GNUInstallDirs` to set installation location 4507 (https://github.com/fmtlib/fmt/pull/610) and fixed warnings 4508 (https://github.com/fmtlib/fmt/pull/536 and 4509 https://github.com/fmtlib/fmt/pull/556). 4510 Thanks @mikecrowe, @evgen231 and @henryiii. 4511 4512# 4.0.0 - 2017-06-27 4513 4514- Removed old compatibility headers `cppformat/*.h` and CMake options 4515 (https://github.com/fmtlib/fmt/pull/527). Thanks @maddinat0r. 4516 4517- Added `string.h` containing `fmt::to_string()` as alternative to 4518 `std::to_string()` as well as other string writer functionality 4519 (https://github.com/fmtlib/fmt/issues/326 and 4520 https://github.com/fmtlib/fmt/pull/441): 4521 4522 ```c++ 4523 #include "fmt/string.h" 4524 4525 std::string answer = fmt::to_string(42); 4526 ``` 4527 4528 Thanks @glebov-andrey. 4529 4530- Moved `fmt::printf()` to new `printf.h` header and allowed `%s` as 4531 generic specifier (https://github.com/fmtlib/fmt/pull/453), 4532 made `%.f` more conformant to regular `printf()` 4533 (https://github.com/fmtlib/fmt/pull/490), added custom 4534 writer support (https://github.com/fmtlib/fmt/issues/476) 4535 and implemented missing custom argument formatting 4536 (https://github.com/fmtlib/fmt/pull/339 and 4537 https://github.com/fmtlib/fmt/pull/340): 4538 4539 ```c++ 4540 #include "fmt/printf.h" 4541 4542 // %s format specifier can be used with any argument type. 4543 fmt::printf("%s", 42); 4544 ``` 4545 4546 Thanks @mojoBrendan, @manylegged and @spacemoose. 4547 See also https://github.com/fmtlib/fmt/issues/360, 4548 https://github.com/fmtlib/fmt/issues/335 and 4549 https://github.com/fmtlib/fmt/issues/331. 4550 4551- Added `container.h` containing a `BasicContainerWriter` to write to 4552 containers like `std::vector` 4553 (https://github.com/fmtlib/fmt/pull/450). Thanks @polyvertex. 4554 4555- Added `fmt::join()` function that takes a range and formats its 4556 elements separated by a given string 4557 (https://github.com/fmtlib/fmt/pull/466): 4558 4559 ```c++ 4560 #include "fmt/format.h" 4561 4562 std::vector<double> v = {1.2, 3.4, 5.6}; 4563 // Prints "(+01.20, +03.40, +05.60)". 4564 fmt::print("({:+06.2f})", fmt::join(v.begin(), v.end(), ", ")); 4565 ``` 4566 4567 Thanks @olivier80. 4568 4569- Added support for custom formatting specifications to simplify 4570 customization of built-in formatting 4571 (https://github.com/fmtlib/fmt/pull/444). Thanks @polyvertex. 4572 See also https://github.com/fmtlib/fmt/issues/439. 4573 4574- Added `fmt::format_system_error()` for error code formatting 4575 (https://github.com/fmtlib/fmt/issues/323 and 4576 https://github.com/fmtlib/fmt/pull/526). Thanks @maddinat0r. 4577 4578- Added thread-safe `fmt::localtime()` and `fmt::gmtime()` as 4579 replacement for the standard version to `time.h` 4580 (https://github.com/fmtlib/fmt/pull/396). Thanks @codicodi. 4581 4582- Internal improvements to `NamedArg` and `ArgLists` 4583 (https://github.com/fmtlib/fmt/pull/389 and 4584 https://github.com/fmtlib/fmt/pull/390). Thanks @chronoxor. 4585 4586- Fixed crash due to bug in `FormatBuf` 4587 (https://github.com/fmtlib/fmt/pull/493). Thanks @effzeh. See also 4588 https://github.com/fmtlib/fmt/issues/480 and 4589 https://github.com/fmtlib/fmt/issues/491. 4590 4591- Fixed handling of wide strings in `fmt::StringWriter`. 4592 4593- Improved compiler error messages 4594 (https://github.com/fmtlib/fmt/issues/357). 4595 4596- Fixed various warnings and issues with various compilers 4597 (https://github.com/fmtlib/fmt/pull/494, 4598 https://github.com/fmtlib/fmt/pull/499, 4599 https://github.com/fmtlib/fmt/pull/483, 4600 https://github.com/fmtlib/fmt/pull/485, 4601 https://github.com/fmtlib/fmt/pull/482, 4602 https://github.com/fmtlib/fmt/pull/475, 4603 https://github.com/fmtlib/fmt/pull/473 and 4604 https://github.com/fmtlib/fmt/pull/414). 4605 Thanks @chronoxor, @zhaohuaxishi, @pkestene, @dschmidt and @0x414c. 4606 4607- Improved CMake: targets are now namespaced 4608 (https://github.com/fmtlib/fmt/pull/511 and 4609 https://github.com/fmtlib/fmt/pull/513), supported 4610 header-only `printf.h` 4611 (https://github.com/fmtlib/fmt/pull/354), fixed issue with 4612 minimal supported library subset 4613 (https://github.com/fmtlib/fmt/issues/418, 4614 https://github.com/fmtlib/fmt/pull/419 and 4615 https://github.com/fmtlib/fmt/pull/420). 4616 Thanks @bjoernthiel, @niosHD, @LogicalKnight and @alabuzhev. 4617 4618- Improved documentation (https://github.com/fmtlib/fmt/pull/393). 4619 Thanks @pwm1234. 4620 4621# 3.0.2 - 2017-06-14 4622 4623- Added `FMT_VERSION` macro 4624 (https://github.com/fmtlib/fmt/issues/411). 4625- Used `FMT_NULL` instead of literal `0` 4626 (https://github.com/fmtlib/fmt/pull/409). Thanks @alabuzhev. 4627- Added extern templates for `format_float` 4628 (https://github.com/fmtlib/fmt/issues/413). 4629- Fixed implicit conversion issue 4630 (https://github.com/fmtlib/fmt/issues/507). 4631- Fixed signbit detection 4632 (https://github.com/fmtlib/fmt/issues/423). 4633- Fixed naming collision 4634 (https://github.com/fmtlib/fmt/issues/425). 4635- Fixed missing intrinsic for C++/CLI 4636 (https://github.com/fmtlib/fmt/pull/457). Thanks @calumr. 4637- Fixed Android detection 4638 (https://github.com/fmtlib/fmt/pull/458). Thanks @Gachapen. 4639- Use lean `windows.h` if not in header-only mode 4640 (https://github.com/fmtlib/fmt/pull/503). Thanks @Quentin01. 4641- Fixed issue with CMake exporting C++11 flag 4642 (https://github.com/fmtlib/fmt/pull/455). Thanks @EricWF. 4643- Fixed issue with nvcc and MSVC compiler bug and MinGW 4644 (https://github.com/fmtlib/fmt/issues/505). 4645- Fixed DLL issues (https://github.com/fmtlib/fmt/pull/469 and 4646 https://github.com/fmtlib/fmt/pull/502). 4647 Thanks @richardeakin and @AndreasSchoenle. 4648- Fixed test compilation under FreeBSD 4649 (https://github.com/fmtlib/fmt/issues/433). 4650- Fixed various warnings 4651 (https://github.com/fmtlib/fmt/pull/403, 4652 https://github.com/fmtlib/fmt/pull/410 and 4653 https://github.com/fmtlib/fmt/pull/510). 4654 Thanks @Lecetem, @chenhayat and @trozen. 4655- Worked around a broken `__builtin_clz` in clang with MS codegen 4656 (https://github.com/fmtlib/fmt/issues/519). 4657- Removed redundant include 4658 (https://github.com/fmtlib/fmt/issues/479). 4659- Fixed documentation issues. 4660 4661# 3.0.1 - 2016-11-01 4662 4663- Fixed handling of thousands separator 4664 (https://github.com/fmtlib/fmt/issues/353). 4665- Fixed handling of `unsigned char` strings 4666 (https://github.com/fmtlib/fmt/issues/373). 4667- Corrected buffer growth when formatting time 4668 (https://github.com/fmtlib/fmt/issues/367). 4669- Removed warnings under MSVC and clang 4670 (https://github.com/fmtlib/fmt/issues/318, 4671 https://github.com/fmtlib/fmt/issues/250, also merged 4672 https://github.com/fmtlib/fmt/pull/385 and 4673 https://github.com/fmtlib/fmt/pull/361). 4674 Thanks @jcelerier and @nmoehrle. 4675- Fixed compilation issues under Android 4676 (https://github.com/fmtlib/fmt/pull/327, 4677 https://github.com/fmtlib/fmt/issues/345 and 4678 https://github.com/fmtlib/fmt/pull/381), FreeBSD 4679 (https://github.com/fmtlib/fmt/pull/358), Cygwin 4680 (https://github.com/fmtlib/fmt/issues/388), MinGW 4681 (https://github.com/fmtlib/fmt/issues/355) as well as other 4682 issues (https://github.com/fmtlib/fmt/issues/350, 4683 https://github.com/fmtlib/fmt/issues/355, 4684 https://github.com/fmtlib/fmt/pull/348, 4685 https://github.com/fmtlib/fmt/pull/402, 4686 https://github.com/fmtlib/fmt/pull/405). 4687 Thanks @dpantele, @hghwng, @arvedarved, @LogicalKnight and @JanHellwig. 4688- Fixed some documentation issues and extended specification 4689 (https://github.com/fmtlib/fmt/issues/320, 4690 https://github.com/fmtlib/fmt/pull/333, 4691 https://github.com/fmtlib/fmt/issues/347, 4692 https://github.com/fmtlib/fmt/pull/362). Thanks @smellman. 4693 4694# 3.0.0 - 2016-05-07 4695 4696- The project has been renamed from C++ Format (cppformat) to fmt for 4697 consistency with the used namespace and macro prefix 4698 (https://github.com/fmtlib/fmt/issues/307). Library headers 4699 are now located in the `fmt` directory: 4700 4701 ```c++ 4702 #include "fmt/format.h" 4703 ``` 4704 4705 Including `format.h` from the `cppformat` directory is deprecated 4706 but works via a proxy header which will be removed in the next major 4707 version. 4708 4709 The documentation is now available at <https://fmt.dev>. 4710 4711- Added support for 4712 [strftime](http://en.cppreference.com/w/cpp/chrono/c/strftime)-like 4713 [date and time 4714 formatting](https://fmt.dev/3.0.0/api.html#date-and-time-formatting) 4715 (https://github.com/fmtlib/fmt/issues/283): 4716 4717 ```c++ 4718 #include "fmt/time.h" 4719 4720 std::time_t t = std::time(nullptr); 4721 // Prints "The date is 2016-04-29." (with the current date) 4722 fmt::print("The date is {:%Y-%m-%d}.", *std::localtime(&t)); 4723 ``` 4724 4725- `std::ostream` support including formatting of user-defined types 4726 that provide overloaded `operator<<` has been moved to 4727 `fmt/ostream.h`: 4728 4729 ```c++ 4730 #include "fmt/ostream.h" 4731 4732 class Date { 4733 int year_, month_, day_; 4734 public: 4735 Date(int year, int month, int day) : year_(year), month_(month), day_(day) {} 4736 4737 friend std::ostream &operator<<(std::ostream &os, const Date &d) { 4738 return os << d.year_ << '-' << d.month_ << '-' << d.day_; 4739 } 4740 }; 4741 4742 std::string s = fmt::format("The date is {}", Date(2012, 12, 9)); 4743 // s == "The date is 2012-12-9" 4744 ``` 4745 4746- Added support for [custom argument 4747 formatters](https://fmt.dev/3.0.0/api.html#argument-formatters) 4748 (https://github.com/fmtlib/fmt/issues/235). 4749 4750- Added support for locale-specific integer formatting with the `n` 4751 specifier (https://github.com/fmtlib/fmt/issues/305): 4752 4753 ```c++ 4754 std::setlocale(LC_ALL, "en_US.utf8"); 4755 fmt::print("cppformat: {:n}\n", 1234567); // prints 1,234,567 4756 ``` 4757 4758- Sign is now preserved when formatting an integer with an incorrect 4759 `printf` format specifier 4760 (https://github.com/fmtlib/fmt/issues/265): 4761 4762 ```c++ 4763 fmt::printf("%lld", -42); // prints -42 4764 ``` 4765 4766 Note that it would be an undefined behavior in `std::printf`. 4767 4768- Length modifiers such as `ll` are now optional in printf formatting 4769 functions and the correct type is determined automatically 4770 (https://github.com/fmtlib/fmt/issues/255): 4771 4772 ```c++ 4773 fmt::printf("%d", std::numeric_limits<long long>::max()); 4774 ``` 4775 4776 Note that it would be an undefined behavior in `std::printf`. 4777 4778- Added initial support for custom formatters 4779 (https://github.com/fmtlib/fmt/issues/231). 4780 4781- Fixed detection of user-defined literal support on Intel C++ 4782 compiler (https://github.com/fmtlib/fmt/issues/311, 4783 https://github.com/fmtlib/fmt/pull/312). 4784 Thanks @dean0x7d and @speth. 4785 4786- Reduced compile time 4787 (https://github.com/fmtlib/fmt/pull/243, 4788 https://github.com/fmtlib/fmt/pull/249, 4789 https://github.com/fmtlib/fmt/issues/317): 4790 4791  4792 4793  4794 4795 Thanks @dean0x7d. 4796 4797- Compile test fixes (https://github.com/fmtlib/fmt/pull/313). 4798 Thanks @dean0x7d. 4799 4800- Documentation fixes (https://github.com/fmtlib/fmt/pull/239, 4801 https://github.com/fmtlib/fmt/issues/248, 4802 https://github.com/fmtlib/fmt/issues/252, 4803 https://github.com/fmtlib/fmt/pull/258, 4804 https://github.com/fmtlib/fmt/issues/260, 4805 https://github.com/fmtlib/fmt/issues/301, 4806 https://github.com/fmtlib/fmt/pull/309). 4807 Thanks @ReadmeCritic @Gachapen and @jwilk. 4808 4809- Fixed compiler and sanitizer warnings 4810 (https://github.com/fmtlib/fmt/issues/244, 4811 https://github.com/fmtlib/fmt/pull/256, 4812 https://github.com/fmtlib/fmt/pull/259, 4813 https://github.com/fmtlib/fmt/issues/263, 4814 https://github.com/fmtlib/fmt/issues/274, 4815 https://github.com/fmtlib/fmt/pull/277, 4816 https://github.com/fmtlib/fmt/pull/286, 4817 https://github.com/fmtlib/fmt/issues/291, 4818 https://github.com/fmtlib/fmt/issues/296, 4819 https://github.com/fmtlib/fmt/issues/308). 4820 Thanks @mwinterb, @pweiskircher and @Naios. 4821 4822- Improved compatibility with Windows Store apps 4823 (https://github.com/fmtlib/fmt/issues/280, 4824 https://github.com/fmtlib/fmt/pull/285) Thanks @mwinterb. 4825 4826- Added tests of compatibility with older C++ standards 4827 (https://github.com/fmtlib/fmt/pull/273). Thanks @niosHD. 4828 4829- Fixed Android build 4830 (https://github.com/fmtlib/fmt/pull/271). Thanks @newnon. 4831 4832- Changed `ArgMap` to be backed by a vector instead of a map. 4833 (https://github.com/fmtlib/fmt/issues/261, 4834 https://github.com/fmtlib/fmt/pull/262). Thanks @mwinterb. 4835 4836- Added `fprintf` overload that writes to a `std::ostream` 4837 (https://github.com/fmtlib/fmt/pull/251). 4838 Thanks @nickhutchinson. 4839 4840- Export symbols when building a Windows DLL 4841 (https://github.com/fmtlib/fmt/pull/245). 4842 Thanks @macdems. 4843 4844- Fixed compilation on Cygwin 4845 (https://github.com/fmtlib/fmt/issues/304). 4846 4847- Implemented a workaround for a bug in Apple LLVM version 4.2 of 4848 clang (https://github.com/fmtlib/fmt/issues/276). 4849 4850- Implemented a workaround for Google Test bug 4851 https://github.com/google/googletest/issues/705 on gcc 6 4852 (https://github.com/fmtlib/fmt/issues/268). Thanks @octoploid. 4853 4854- Removed Biicode support because the latter has been discontinued. 4855 4856# 2.1.1 - 2016-04-11 4857 4858- The install location for generated CMake files is now configurable 4859 via the `FMT_CMAKE_DIR` CMake variable 4860 (https://github.com/fmtlib/fmt/pull/299). Thanks @niosHD. 4861- Documentation fixes 4862 (https://github.com/fmtlib/fmt/issues/252). 4863 4864# 2.1.0 - 2016-03-21 4865 4866- Project layout and build system improvements 4867 (https://github.com/fmtlib/fmt/pull/267): 4868 4869 - The code have been moved to the `cppformat` directory. Including 4870 `format.h` from the top-level directory is deprecated but works 4871 via a proxy header which will be removed in the next major 4872 version. 4873 - C++ Format CMake targets now have proper interface definitions. 4874 - Installed version of the library now supports the header-only 4875 configuration. 4876 - Targets `doc`, `install`, and `test` are now disabled if C++ 4877 Format is included as a CMake subproject. They can be enabled by 4878 setting `FMT_DOC`, `FMT_INSTALL`, and `FMT_TEST` in the parent 4879 project. 4880 4881 Thanks @niosHD. 4882 4883# 2.0.1 - 2016-03-13 4884 4885- Improved CMake find and package support 4886 (https://github.com/fmtlib/fmt/issues/264). Thanks @niosHD. 4887- Fix compile error with Android NDK and mingw32 4888 (https://github.com/fmtlib/fmt/issues/241). Thanks @Gachapen. 4889- Documentation fixes 4890 (https://github.com/fmtlib/fmt/issues/248, 4891 https://github.com/fmtlib/fmt/issues/260). 4892 4893# 2.0.0 - 2015-12-01 4894 4895## General 4896 4897- \[Breaking\] Named arguments 4898 (https://github.com/fmtlib/fmt/pull/169, 4899 https://github.com/fmtlib/fmt/pull/173, 4900 https://github.com/fmtlib/fmt/pull/174): 4901 4902 ```c++ 4903 fmt::print("The answer is {answer}.", fmt::arg("answer", 42)); 4904 ``` 4905 4906 Thanks @jamboree. 4907 4908- \[Experimental\] User-defined literals for format and named 4909 arguments (https://github.com/fmtlib/fmt/pull/204, 4910 https://github.com/fmtlib/fmt/pull/206, 4911 https://github.com/fmtlib/fmt/pull/207): 4912 4913 ```c++ 4914 using namespace fmt::literals; 4915 fmt::print("The answer is {answer}.", "answer"_a=42); 4916 ``` 4917 4918 Thanks @dean0x7d. 4919 4920- \[Breaking\] Formatting of more than 16 arguments is now supported 4921 when using variadic templates 4922 (https://github.com/fmtlib/fmt/issues/141). Thanks @Shauren. 4923 4924- Runtime width specification 4925 (https://github.com/fmtlib/fmt/pull/168): 4926 4927 ```c++ 4928 fmt::format("{0:{1}}", 42, 5); // gives " 42" 4929 ``` 4930 4931 Thanks @jamboree. 4932 4933- \[Breaking\] Enums are now formatted with an overloaded 4934 `std::ostream` insertion operator (`operator<<`) if available 4935 (https://github.com/fmtlib/fmt/issues/232). 4936 4937- \[Breaking\] Changed default `bool` format to textual, \"true\" or 4938 \"false\" (https://github.com/fmtlib/fmt/issues/170): 4939 4940 ```c++ 4941 fmt::print("{}", true); // prints "true" 4942 ``` 4943 4944 To print `bool` as a number use numeric format specifier such as 4945 `d`: 4946 4947 ```c++ 4948 fmt::print("{:d}", true); // prints "1" 4949 ``` 4950 4951- `fmt::printf` and `fmt::sprintf` now support formatting of `bool` 4952 with the `%s` specifier giving textual output, \"true\" or \"false\" 4953 (https://github.com/fmtlib/fmt/pull/223): 4954 4955 ```c++ 4956 fmt::printf("%s", true); // prints "true" 4957 ``` 4958 4959 Thanks @LarsGullik. 4960 4961- \[Breaking\] `signed char` and `unsigned char` are now formatted as 4962 integers by default 4963 (https://github.com/fmtlib/fmt/pull/217). 4964 4965- \[Breaking\] Pointers to C strings can now be formatted with the `p` 4966 specifier (https://github.com/fmtlib/fmt/pull/223): 4967 4968 ```c++ 4969 fmt::print("{:p}", "test"); // prints pointer value 4970 ``` 4971 4972 Thanks @LarsGullik. 4973 4974- \[Breaking\] `fmt::printf` and `fmt::sprintf` now print null 4975 pointers as `(nil)` and null strings as `(null)` for consistency 4976 with glibc (https://github.com/fmtlib/fmt/pull/226). 4977 Thanks @LarsGullik. 4978 4979- \[Breaking\] `fmt::(s)printf` now supports formatting of objects of 4980 user-defined types that provide an overloaded `std::ostream` 4981 insertion operator (`operator<<`) 4982 (https://github.com/fmtlib/fmt/issues/201): 4983 4984 ```c++ 4985 fmt::printf("The date is %s", Date(2012, 12, 9)); 4986 ``` 4987 4988- \[Breaking\] The `Buffer` template is now part of the public API and 4989 can be used to implement custom memory buffers 4990 (https://github.com/fmtlib/fmt/issues/140). Thanks @polyvertex. 4991 4992- \[Breaking\] Improved compatibility between `BasicStringRef` and 4993 [std::experimental::basic_string_view]( 4994 http://en.cppreference.com/w/cpp/experimental/basic_string_view) 4995 (https://github.com/fmtlib/fmt/issues/100, 4996 https://github.com/fmtlib/fmt/issues/159, 4997 https://github.com/fmtlib/fmt/issues/183): 4998 4999 - Comparison operators now compare string content, not pointers 5000 - `BasicStringRef::c_str` replaced by `BasicStringRef::data` 5001 - `BasicStringRef` is no longer assumed to be null-terminated 5002 5003 References to null-terminated strings are now represented by a new 5004 class, `BasicCStringRef`. 5005 5006- Dependency on pthreads introduced by Google Test is now optional 5007 (https://github.com/fmtlib/fmt/issues/185). 5008 5009- New CMake options `FMT_DOC`, `FMT_INSTALL` and `FMT_TEST` to control 5010 generation of `doc`, `install` and `test` targets respectively, on 5011 by default (https://github.com/fmtlib/fmt/issues/197, 5012 https://github.com/fmtlib/fmt/issues/198, 5013 https://github.com/fmtlib/fmt/issues/200). Thanks @maddinat0r. 5014 5015- `noexcept` is now used when compiling with MSVC2015 5016 (https://github.com/fmtlib/fmt/pull/215). Thanks @dmkrepo. 5017 5018- Added an option to disable use of `windows.h` when 5019 `FMT_USE_WINDOWS_H` is defined as 0 before including `format.h` 5020 (https://github.com/fmtlib/fmt/issues/171). Thanks @alfps. 5021 5022- \[Breaking\] `windows.h` is now included with `NOMINMAX` unless 5023 `FMT_WIN_MINMAX` is defined. This is done to prevent breaking code 5024 using `std::min` and `std::max` and only affects the header-only 5025 configuration (https://github.com/fmtlib/fmt/issues/152, 5026 https://github.com/fmtlib/fmt/pull/153, 5027 https://github.com/fmtlib/fmt/pull/154). Thanks @DevO2012. 5028 5029- Improved support for custom character types 5030 (https://github.com/fmtlib/fmt/issues/171). Thanks @alfps. 5031 5032- Added an option to disable use of IOStreams when `FMT_USE_IOSTREAMS` 5033 is defined as 0 before including `format.h` 5034 (https://github.com/fmtlib/fmt/issues/205, 5035 https://github.com/fmtlib/fmt/pull/208). Thanks @JodiTheTigger. 5036 5037- Improved detection of `isnan`, `isinf` and `signbit`. 5038 5039## Optimization 5040 5041- Made formatting of user-defined types more efficient with a custom 5042 stream buffer (https://github.com/fmtlib/fmt/issues/92, 5043 https://github.com/fmtlib/fmt/pull/230). Thanks @NotImplemented. 5044- Further improved performance of `fmt::Writer` on integer formatting 5045 and fixed a minor regression. Now it is \~7% faster than 5046 `karma::generate` on Karma\'s benchmark 5047 (https://github.com/fmtlib/fmt/issues/186). 5048- \[Breaking\] Reduced [compiled code 5049 size](https://github.com/fmtlib/fmt#compile-time-and-code-bloat) 5050 (https://github.com/fmtlib/fmt/issues/143, 5051 https://github.com/fmtlib/fmt/pull/149). 5052 5053## Distribution 5054 5055- \[Breaking\] Headers are now installed in 5056 `${CMAKE_INSTALL_PREFIX}/include/cppformat` 5057 (https://github.com/fmtlib/fmt/issues/178). Thanks @jackyf. 5058 5059- \[Breaking\] Changed the library name from `format` to `cppformat` 5060 for consistency with the project name and to avoid potential 5061 conflicts (https://github.com/fmtlib/fmt/issues/178). 5062 Thanks @jackyf. 5063 5064- C++ Format is now available in [Debian](https://www.debian.org/) 5065 GNU/Linux 5066 ([stretch](https://packages.debian.org/source/stretch/cppformat), 5067 [sid](https://packages.debian.org/source/sid/cppformat)) and derived 5068 distributions such as 5069 [Ubuntu](https://launchpad.net/ubuntu/+source/cppformat) 15.10 and 5070 later (https://github.com/fmtlib/fmt/issues/155): 5071 5072 $ sudo apt-get install libcppformat1-dev 5073 5074 Thanks @jackyf. 5075 5076- [Packages for Fedora and 5077 RHEL](https://admin.fedoraproject.org/pkgdb/package/cppformat/) are 5078 now available. Thanks Dave Johansen. 5079 5080- C++ Format can now be installed via [Homebrew](http://brew.sh/) on 5081 OS X (https://github.com/fmtlib/fmt/issues/157): 5082 5083 $ brew install cppformat 5084 5085 Thanks @ortho and Anatoliy Bulukin. 5086 5087## Documentation 5088 5089- Migrated from ReadTheDocs to GitHub Pages for better responsiveness 5090 and reliability (https://github.com/fmtlib/fmt/issues/128). 5091 New documentation address is <http://cppformat.github.io/>. 5092- Added [Building thedocumentation]( 5093 https://fmt.dev/2.0.0/usage.html#building-the-documentation) 5094 section to the documentation. 5095- Documentation build script is now compatible with Python 3 and newer 5096 pip versions. (https://github.com/fmtlib/fmt/pull/189, 5097 https://github.com/fmtlib/fmt/issues/209). 5098 Thanks @JodiTheTigger and @xentec. 5099- Documentation fixes and improvements 5100 (https://github.com/fmtlib/fmt/issues/36, 5101 https://github.com/fmtlib/fmt/issues/75, 5102 https://github.com/fmtlib/fmt/issues/125, 5103 https://github.com/fmtlib/fmt/pull/160, 5104 https://github.com/fmtlib/fmt/pull/161, 5105 https://github.com/fmtlib/fmt/issues/162, 5106 https://github.com/fmtlib/fmt/issues/165, 5107 https://github.com/fmtlib/fmt/issues/210). 5108 Thanks @syohex. 5109- Fixed out-of-tree documentation build 5110 (https://github.com/fmtlib/fmt/issues/177). Thanks @jackyf. 5111 5112## Fixes 5113 5114- Fixed `initializer_list` detection 5115 (https://github.com/fmtlib/fmt/issues/136). Thanks @Gachapen. 5116 5117- \[Breaking\] Fixed formatting of enums with numeric format 5118 specifiers in `fmt::(s)printf` 5119 (https://github.com/fmtlib/fmt/issues/131, 5120 https://github.com/fmtlib/fmt/issues/139): 5121 5122 ```c++ 5123 enum { ANSWER = 42 }; 5124 fmt::printf("%d", ANSWER); 5125 ``` 5126 5127 Thanks @Naios. 5128 5129- Improved compatibility with old versions of MinGW 5130 (https://github.com/fmtlib/fmt/issues/129, 5131 https://github.com/fmtlib/fmt/pull/130, 5132 https://github.com/fmtlib/fmt/issues/132). Thanks @cstamford. 5133 5134- Fixed a compile error on MSVC with disabled exceptions 5135 (https://github.com/fmtlib/fmt/issues/144). 5136 5137- Added a workaround for broken implementation of variadic templates 5138 in MSVC2012 (https://github.com/fmtlib/fmt/issues/148). 5139 5140- Placed the anonymous namespace within `fmt` namespace for the 5141 header-only configuration (https://github.com/fmtlib/fmt/issues/171). 5142 Thanks @alfps. 5143 5144- Fixed issues reported by Coverity Scan 5145 (https://github.com/fmtlib/fmt/issues/187, 5146 https://github.com/fmtlib/fmt/issues/192). 5147 5148- Implemented a workaround for a name lookup bug in MSVC2010 5149 (https://github.com/fmtlib/fmt/issues/188). 5150 5151- Fixed compiler warnings 5152 (https://github.com/fmtlib/fmt/issues/95, 5153 https://github.com/fmtlib/fmt/issues/96, 5154 https://github.com/fmtlib/fmt/pull/114, 5155 https://github.com/fmtlib/fmt/issues/135, 5156 https://github.com/fmtlib/fmt/issues/142, 5157 https://github.com/fmtlib/fmt/issues/145, 5158 https://github.com/fmtlib/fmt/issues/146, 5159 https://github.com/fmtlib/fmt/issues/158, 5160 https://github.com/fmtlib/fmt/issues/163, 5161 https://github.com/fmtlib/fmt/issues/175, 5162 https://github.com/fmtlib/fmt/issues/190, 5163 https://github.com/fmtlib/fmt/pull/191, 5164 https://github.com/fmtlib/fmt/issues/194, 5165 https://github.com/fmtlib/fmt/pull/196, 5166 https://github.com/fmtlib/fmt/issues/216, 5167 https://github.com/fmtlib/fmt/pull/218, 5168 https://github.com/fmtlib/fmt/pull/220, 5169 https://github.com/fmtlib/fmt/pull/229, 5170 https://github.com/fmtlib/fmt/issues/233, 5171 https://github.com/fmtlib/fmt/issues/234, 5172 https://github.com/fmtlib/fmt/pull/236, 5173 https://github.com/fmtlib/fmt/issues/281, 5174 https://github.com/fmtlib/fmt/issues/289). 5175 Thanks @seanmiddleditch, @dixlorenz, @CarterLi, @Naios, @fmatthew5876, 5176 @LevskiWeng, @rpopescu, @gabime, @cubicool, @jkflying, @LogicalKnight, 5177 @inguin and @Jopie64. 5178 5179- Fixed portability issues (mostly causing test failures) on ARM, 5180 ppc64, ppc64le, s390x and SunOS 5.11 i386 5181 (https://github.com/fmtlib/fmt/issues/138, 5182 https://github.com/fmtlib/fmt/issues/179, 5183 https://github.com/fmtlib/fmt/issues/180, 5184 https://github.com/fmtlib/fmt/issues/202, 5185 https://github.com/fmtlib/fmt/issues/225, [Red Hat Bugzilla 5186 Bug 1260297](https://bugzilla.redhat.com/show_bug.cgi?id=1260297)). 5187 Thanks @Naios, @jackyf and Dave Johansen. 5188 5189- Fixed a name conflict with macro `free` defined in `crtdbg.h` when 5190 `_CRTDBG_MAP_ALLOC` is set (https://github.com/fmtlib/fmt/issues/211). 5191 5192- Fixed shared library build on OS X 5193 (https://github.com/fmtlib/fmt/pull/212). Thanks @dean0x7d. 5194 5195- Fixed an overload conflict on MSVC when `/Zc:wchar_t-` option is 5196 specified (https://github.com/fmtlib/fmt/pull/214). 5197 Thanks @slavanap. 5198 5199- Improved compatibility with MSVC 2008 5200 (https://github.com/fmtlib/fmt/pull/236). Thanks @Jopie64. 5201 5202- Improved compatibility with bcc32 5203 (https://github.com/fmtlib/fmt/issues/227). 5204 5205- Fixed `static_assert` detection on Clang 5206 (https://github.com/fmtlib/fmt/pull/228). Thanks @dean0x7d. 5207 5208# 1.1.0 - 2015-03-06 5209 5210- Added `BasicArrayWriter`, a class template that provides operations 5211 for formatting and writing data into a fixed-size array 5212 (https://github.com/fmtlib/fmt/issues/105 and 5213 https://github.com/fmtlib/fmt/issues/122): 5214 5215 ```c++ 5216 char buffer[100]; 5217 fmt::ArrayWriter w(buffer); 5218 w.write("The answer is {}", 42); 5219 ``` 5220 5221- Added [0 A.D.](http://play0ad.com/) and [PenUltima Online 5222 (POL)](http://www.polserver.com/) to the list of notable projects 5223 using C++ Format. 5224 5225- C++ Format now uses MSVC intrinsics for better formatting performance 5226 (https://github.com/fmtlib/fmt/pull/115, 5227 https://github.com/fmtlib/fmt/pull/116, 5228 https://github.com/fmtlib/fmt/pull/118 and 5229 https://github.com/fmtlib/fmt/pull/121). Previously these 5230 optimizations where only used on GCC and Clang. 5231 Thanks @CarterLi and @objectx. 5232 5233- CMake install target 5234 (https://github.com/fmtlib/fmt/pull/119). Thanks @TrentHouliston. 5235 5236 You can now install C++ Format with `make install` command. 5237 5238- Improved [Biicode](http://www.biicode.com/) support 5239 (https://github.com/fmtlib/fmt/pull/98 and 5240 https://github.com/fmtlib/fmt/pull/104). 5241 Thanks @MariadeAnton and @franramirez688. 5242 5243- Improved support for building with [Android NDK]( 5244 https://developer.android.com/tools/sdk/ndk/index.html) 5245 (https://github.com/fmtlib/fmt/pull/107). Thanks @newnon. 5246 5247 The [android-ndk-example](https://github.com/fmtlib/android-ndk-example) 5248 repository provides and example of using C++ Format with Android NDK: 5249 5250  5251 5252- Improved documentation of `SystemError` and `WindowsError` 5253 (https://github.com/fmtlib/fmt/issues/54). 5254 5255- Various code improvements 5256 (https://github.com/fmtlib/fmt/pull/110, 5257 https://github.com/fmtlib/fmt/pull/111 5258 https://github.com/fmtlib/fmt/pull/112). Thanks @CarterLi. 5259 5260- Improved compile-time errors when formatting wide into narrow 5261 strings (https://github.com/fmtlib/fmt/issues/117). 5262 5263- Fixed `BasicWriter::write` without formatting arguments when C++11 5264 support is disabled 5265 (https://github.com/fmtlib/fmt/issues/109). 5266 5267- Fixed header-only build on OS X with GCC 4.9 5268 (https://github.com/fmtlib/fmt/issues/124). 5269 5270- Fixed packaging issues (https://github.com/fmtlib/fmt/issues/94). 5271 5272- Added [changelog](https://github.com/fmtlib/fmt/blob/master/ChangeLog.md) 5273 (https://github.com/fmtlib/fmt/issues/103). 5274 5275# 1.0.0 - 2015-02-05 5276 5277- Add support for a header-only configuration when `FMT_HEADER_ONLY` 5278 is defined before including `format.h`: 5279 5280 ```c++ 5281 #define FMT_HEADER_ONLY 5282 #include "format.h" 5283 ``` 5284 5285- Compute string length in the constructor of `BasicStringRef` instead 5286 of the `size` method 5287 (https://github.com/fmtlib/fmt/issues/79). This eliminates 5288 size computation for string literals on reasonable optimizing 5289 compilers. 5290 5291- Fix formatting of types with overloaded `operator <<` for 5292 `std::wostream` (https://github.com/fmtlib/fmt/issues/86): 5293 5294 ```c++ 5295 fmt::format(L"The date is {0}", Date(2012, 12, 9)); 5296 ``` 5297 5298- Fix linkage of tests on Arch Linux 5299 (https://github.com/fmtlib/fmt/issues/89). 5300 5301- Allow precision specifier for non-float arguments 5302 (https://github.com/fmtlib/fmt/issues/90): 5303 5304 ```c++ 5305 fmt::print("{:.3}\n", "Carpet"); // prints "Car" 5306 ``` 5307 5308- Fix build on Android NDK (https://github.com/fmtlib/fmt/issues/93). 5309 5310- Improvements to documentation build procedure. 5311 5312- Remove `FMT_SHARED` CMake variable in favor of standard [BUILD_SHARED_LIBS]( 5313 http://www.cmake.org/cmake/help/v3.0/variable/BUILD_SHARED_LIBS.html). 5314 5315- Fix error handling in `fmt::fprintf`. 5316 5317- Fix a number of warnings. 5318 5319# 0.12.0 - 2014-10-25 5320 5321- \[Breaking\] Improved separation between formatting and buffer 5322 management. `Writer` is now a base class that cannot be instantiated 5323 directly. The new `MemoryWriter` class implements the default buffer 5324 management with small allocations done on stack. So `fmt::Writer` 5325 should be replaced with `fmt::MemoryWriter` in variable 5326 declarations. 5327 5328 Old code: 5329 5330 ```c++ 5331 fmt::Writer w; 5332 ``` 5333 5334 New code: 5335 5336 ```c++ 5337 fmt::MemoryWriter w; 5338 ``` 5339 5340 If you pass `fmt::Writer` by reference, you can continue to do so: 5341 5342 ```c++ 5343 void f(fmt::Writer &w); 5344 ``` 5345 5346 This doesn\'t affect the formatting API. 5347 5348- Support for custom memory allocators 5349 (https://github.com/fmtlib/fmt/issues/69) 5350 5351- Formatting functions now accept [signed char]{.title-ref} and 5352 [unsigned char]{.title-ref} strings as arguments 5353 (https://github.com/fmtlib/fmt/issues/73): 5354 5355 ```c++ 5356 auto s = format("GLSL version: {}", glGetString(GL_VERSION)); 5357 ``` 5358 5359- Reduced code bloat. According to the new [benchmark 5360 results](https://github.com/fmtlib/fmt#compile-time-and-code-bloat), 5361 cppformat is close to `printf` and by the order of magnitude better 5362 than Boost Format in terms of compiled code size. 5363 5364- Improved appearance of the documentation on mobile by using the 5365 [Sphinx Bootstrap 5366 theme](http://ryan-roemer.github.io/sphinx-bootstrap-theme/): 5367 5368 | Old | New | 5369 | --- | --- | 5370 |  |  | 5371 5372# 0.11.0 - 2014-08-21 5373 5374- Safe printf implementation with a POSIX extension for positional 5375 arguments: 5376 5377 ```c++ 5378 fmt::printf("Elapsed time: %.2f seconds", 1.23); 5379 fmt::printf("%1$s, %3$d %2$s", weekday, month, day); 5380 ``` 5381 5382- Arguments of `char` type can now be formatted as integers (Issue 5383 https://github.com/fmtlib/fmt/issues/55): 5384 5385 ```c++ 5386 fmt::format("0x{0:02X}", 'a'); 5387 ``` 5388 5389- Deprecated parts of the API removed. 5390 5391- The library is now built and tested on MinGW with Appveyor in 5392 addition to existing test platforms Linux/GCC, OS X/Clang, 5393 Windows/MSVC. 5394 5395# 0.10.0 - 2014-07-01 5396 5397**Improved API** 5398 5399- All formatting methods are now implemented as variadic functions 5400 instead of using `operator<<` for feeding arbitrary arguments into a 5401 temporary formatter object. This works both with C++11 where 5402 variadic templates are used and with older standards where variadic 5403 functions are emulated by providing lightweight wrapper functions 5404 defined with the `FMT_VARIADIC` macro. You can use this macro for 5405 defining your own portable variadic functions: 5406 5407 ```c++ 5408 void report_error(const char *format, const fmt::ArgList &args) { 5409 fmt::print("Error: {}"); 5410 fmt::print(format, args); 5411 } 5412 FMT_VARIADIC(void, report_error, const char *) 5413 5414 report_error("file not found: {}", path); 5415 ``` 5416 5417 Apart from a more natural syntax, this also improves performance as 5418 there is no need to construct temporary formatter objects and 5419 control arguments\' lifetimes. Because the wrapper functions are 5420 very lightweight, this doesn\'t cause code bloat even in pre-C++11 5421 mode. 5422 5423- Simplified common case of formatting an `std::string`. Now it 5424 requires a single function call: 5425 5426 ```c++ 5427 std::string s = format("The answer is {}.", 42); 5428 ``` 5429 5430 Previously it required 2 function calls: 5431 5432 ```c++ 5433 std::string s = str(Format("The answer is {}.") << 42); 5434 ``` 5435 5436 Instead of unsafe `c_str` function, `fmt::Writer` should be used 5437 directly to bypass creation of `std::string`: 5438 5439 ```c++ 5440 fmt::Writer w; 5441 w.write("The answer is {}.", 42); 5442 w.c_str(); // returns a C string 5443 ``` 5444 5445 This doesn\'t do dynamic memory allocation for small strings and is 5446 less error prone as the lifetime of the string is the same as for 5447 `std::string::c_str` which is well understood (hopefully). 5448 5449- Improved consistency in naming functions that are a part of the 5450 public API. Now all public functions are lowercase following the 5451 standard library conventions. Previously it was a combination of 5452 lowercase and CapitalizedWords. Issue 5453 https://github.com/fmtlib/fmt/issues/50. 5454 5455- Old functions are marked as deprecated and will be removed in the 5456 next release. 5457 5458**Other Changes** 5459 5460- Experimental support for printf format specifications (work in 5461 progress): 5462 5463 ```c++ 5464 fmt::printf("The answer is %d.", 42); 5465 std::string s = fmt::sprintf("Look, a %s!", "string"); 5466 ``` 5467 5468- Support for hexadecimal floating point format specifiers `a` and 5469 `A`: 5470 5471 ```c++ 5472 print("{:a}", -42.0); // Prints -0x1.5p+5 5473 print("{:A}", -42.0); // Prints -0X1.5P+5 5474 ``` 5475 5476- CMake option `FMT_SHARED` that specifies whether to build format as 5477 a shared library (off by default). 5478 5479# 0.9.0 - 2014-05-13 5480 5481- More efficient implementation of variadic formatting functions. 5482 5483- `Writer::Format` now has a variadic overload: 5484 5485 ```c++ 5486 Writer out; 5487 out.Format("Look, I'm {}!", "variadic"); 5488 ``` 5489 5490- For efficiency and consistency with other overloads, variadic 5491 overload of the `Format` function now returns `Writer` instead of 5492 `std::string`. Use the `str` function to convert it to 5493 `std::string`: 5494 5495 ```c++ 5496 std::string s = str(Format("Look, I'm {}!", "variadic")); 5497 ``` 5498 5499- Replaced formatter actions with output sinks: `NoAction` -\> 5500 `NullSink`, `Write` -\> `FileSink`, `ColorWriter` -\> 5501 `ANSITerminalSink`. This improves naming consistency and shouldn\'t 5502 affect client code unless these classes are used directly which 5503 should be rarely needed. 5504 5505- Added `ThrowSystemError` function that formats a message and throws 5506 `SystemError` containing the formatted message and system-specific 5507 error description. For example, the following code 5508 5509 ```c++ 5510 FILE *f = fopen(filename, "r"); 5511 if (!f) 5512 ThrowSystemError(errno, "Failed to open file '{}'") << filename; 5513 ``` 5514 5515 will throw `SystemError` exception with description \"Failed to open 5516 file \'\<filename\>\': No such file or directory\" if file doesn\'t 5517 exist. 5518 5519- Support for AppVeyor continuous integration platform. 5520 5521- `Format` now throws `SystemError` in case of I/O errors. 5522 5523- Improve test infrastructure. Print functions are now tested by 5524 redirecting the output to a pipe. 5525 5526# 0.8.0 - 2014-04-14 5527 5528- Initial release 5529