Remove unnecessary styled overloads
This commit is contained in:
parent
1b663051b5
commit
b250c639bf
@ -679,8 +679,8 @@ struct formatter<detail::styled_arg<T>, Char> : formatter<T, Char> {
|
||||
**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 <typename T>
|
||||
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<remove_cvref_t<T>>{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 <typename T>
|
||||
FMT_CONSTEXPR auto styled(const T& value, detail::color_type color)
|
||||
-> detail::styled_arg<remove_cvref_t<T>> {
|
||||
return detail::styled_arg<remove_cvref_t<T>>{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 <typename T>
|
||||
FMT_CONSTEXPR auto styled(const T& value, emphasis em)
|
||||
-> detail::styled_arg<remove_cvref_t<T>> {
|
||||
return detail::styled_arg<remove_cvref_t<T>>{value, text_style(em)};
|
||||
}
|
||||
|
||||
FMT_MODULE_EXPORT_END
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
|
||||
@ -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) |
|
||||
|
||||
Loading…
Reference in New Issue
Block a user