@@ -1423,6 +1423,14 @@ FMT_CONSTEXPR void handle_int_type_spec(char spec, Handler&& handler) {
1423
1423
}
1424
1424
}
1425
1425
1426
+ template <typename Char, typename Handler>
1427
+ FMT_CONSTEXPR void handle_bool_type_spec (const basic_format_specs<Char>* specs,
1428
+ Handler&& handler) {
1429
+ if (!specs) return handler.on_str ();
1430
+ if (specs->type && specs->type != ' s' ) return handler.on_int ();
1431
+ handler.on_str ();
1432
+ }
1433
+
1426
1434
template <typename ErrorHandler = error_handler, typename Char>
1427
1435
FMT_CONSTEXPR float_specs parse_float_type_spec (
1428
1436
const basic_format_specs<Char>& specs, ErrorHandler&& eh = {}) {
@@ -1542,6 +1550,21 @@ class cstring_type_checker : public ErrorHandler {
1542
1550
FMT_CONSTEXPR void on_pointer () {}
1543
1551
};
1544
1552
1553
+ template <typename ErrorHandler>
1554
+ class bool_type_checker : private ErrorHandler {
1555
+ private:
1556
+ char type_;
1557
+
1558
+ public:
1559
+ FMT_CONSTEXPR explicit bool_type_checker (char type, ErrorHandler eh)
1560
+ : ErrorHandler(eh), type_(type) {}
1561
+
1562
+ FMT_CONSTEXPR void on_int () {
1563
+ handle_int_type_spec (type_, int_type_checker<ErrorHandler>(*this ));
1564
+ }
1565
+ FMT_CONSTEXPR void on_str () {}
1566
+ };
1567
+
1545
1568
template <typename OutputIt, typename Char>
1546
1569
FMT_NOINLINE FMT_CONSTEXPR OutputIt fill (OutputIt it, size_t n,
1547
1570
const fill_t <Char>& fill) {
@@ -3516,10 +3539,13 @@ struct formatter<T, Char,
3516
3539
case detail::type::ulong_long_type:
3517
3540
case detail::type::int128_type:
3518
3541
case detail::type::uint128_type:
3519
- case detail::type::bool_type:
3520
3542
handle_int_type_spec (specs_.type ,
3521
3543
detail::int_type_checker<decltype (eh)>(eh));
3522
3544
break ;
3545
+ case detail::type::bool_type:
3546
+ handle_bool_type_spec (
3547
+ &specs_, detail::bool_type_checker<decltype (eh)>(specs_.type , eh));
3548
+ break ;
3523
3549
case detail::type::char_type:
3524
3550
handle_char_specs (
3525
3551
&specs_, detail::char_specs_checker<decltype (eh)>(specs_.type , eh));
0 commit comments