From b250c639bfd6c650c8d1b350fa63f47fe92121ef Mon Sep 17 00:00:00 2001 From: rbrugo Date: Tue, 8 Mar 2022 16:15:42 +0100 Subject: [PATCH] Remove unnecessary `styled` overloads --- include/fmt/color.h | 36 ++---------------------------------- test/color-test.cc | 2 +- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/include/fmt/color.h b/include/fmt/color.h index cf701002..9ee0da35 100644 --- a/include/fmt/color.h +++ b/include/fmt/color.h @@ -679,8 +679,8 @@ struct formatter, Char> : formatter { **Example**:: fmt::print("Elapsed time: {s:.2f} seconds", - fmt::styled(1.23, fmt::fg(fmt::colors::green) | - fmt::bg(fmt::color::blue))); \endrst + fmt::styled(1.23, fmt::fg(fmt::colors::green) | fmt::bg(fmt::color::blue))); + \endrst */ template FMT_CONSTEXPR auto styled(const T& value, text_style ts = {}) @@ -688,38 +688,6 @@ FMT_CONSTEXPR auto styled(const T& value, text_style ts = {}) return detail::styled_arg>{value, ts}; } -/** - \rst - Returns an argument surrounded by the ANSI escape sequences of the color, - to be used in a formatting function. - - **Example**:: - - fmt::print("Elapsed time: {s:.2f} seconds", fmt::styled(1.23, - fmt::colors::green)); \endrst - */ -template -FMT_CONSTEXPR auto styled(const T& value, detail::color_type color) - -> detail::styled_arg> { - return detail::styled_arg>{value, fg(color)}; -} - -/** - \rst - Returns an argument associated with an emphasis, to be used - in a formatting function. - - **Example**:: - - fmt::print("Elapsed time: {s:.2f} seconds", fmt::styled(1.23, - fmt::emphasis::italic)); \endrst - */ -template -FMT_CONSTEXPR auto styled(const T& value, emphasis em) - -> detail::styled_arg> { - return detail::styled_arg>{value, text_style(em)}; -} - FMT_MODULE_EXPORT_END FMT_END_NAMESPACE diff --git a/test/color-test.cc b/test/color-test.cc index 2bb6a4a3..c2ba13a9 100644 --- a/test/color-test.cc +++ b/test/color-test.cc @@ -50,7 +50,7 @@ TEST(color_test, format) { "\x1b[105mtbmagenta\x1b[0m"); EXPECT_EQ(fmt::format(fg(fmt::terminal_color::red), "{}", "foo"), "\x1b[31mfoo\x1b[0m"); - EXPECT_EQ(fmt::format("{}{}", fmt::styled("red", fmt::color::red), + EXPECT_EQ(fmt::format("{}{}", fmt::styled("red", fg(fmt::color::red)), fmt::styled("bold", fmt::emphasis::bold)), "\x1b[38;2;255;000;000mred\x1b[0m\x1b[1mbold\x1b[0m"); EXPECT_EQ(fmt::format("{}", fmt::styled("bar", fg(fmt::color::blue) |