mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-30 15:32:36 +00:00
Minor cleanup
This commit is contained in:
parent
0b5287f8b7
commit
75e892420e
@ -4000,8 +4000,7 @@ struct formatter<T, Char, enable_if_t<detail::has_format_as<T>::value>>
|
||||
template <typename FormatContext>
|
||||
auto format(const T& value, FormatContext& ctx) const -> decltype(ctx.out()) {
|
||||
using base = formatter<detail::format_as_t<T>, Char>;
|
||||
// format functions expect lvalue refs, not rvalues
|
||||
auto&& val = format_as(value);
|
||||
auto&& val = format_as(value); // Make an lvalue reference for format.
|
||||
return base::format(val, ctx);
|
||||
}
|
||||
};
|
||||
|
@ -683,13 +683,13 @@ TEST(ranges_test, input_range_join_overload) {
|
||||
|
||||
namespace views_filter_view_test {
|
||||
struct codec_mask {
|
||||
static constexpr auto kCodecs = std::array{0, 1, 2, 3};
|
||||
int except{};
|
||||
static constexpr auto codecs = std::array{0, 1, 2, 3};
|
||||
int except = 0;
|
||||
};
|
||||
|
||||
auto format_as(codec_mask mask) {
|
||||
// Careful not to capture param by reference here, it will dangle
|
||||
return codec_mask::kCodecs |
|
||||
// Careful not to capture param by reference here, it will dangle.
|
||||
return codec_mask::codecs |
|
||||
std::views::filter([mask](auto c) { return c != mask.except; });
|
||||
}
|
||||
} // namespace views_filter_view_test
|
||||
@ -698,7 +698,7 @@ TEST(ranges_test, format_as_with_ranges_mutable_begin_end) {
|
||||
using namespace views_filter_view_test;
|
||||
{
|
||||
auto make_filter_view = []() {
|
||||
return codec_mask::kCodecs |
|
||||
return codec_mask::codecs |
|
||||
std::views::filter([](auto c) { return c != 2; });
|
||||
};
|
||||
auto r = make_filter_view();
|
||||
@ -707,11 +707,11 @@ TEST(ranges_test, format_as_with_ranges_mutable_begin_end) {
|
||||
}
|
||||
|
||||
{
|
||||
const codec_mask const_mask{2};
|
||||
codec_mask mask{2};
|
||||
auto mask = codec_mask{2};
|
||||
const auto const_mask = codec_mask{2};
|
||||
|
||||
EXPECT_EQ("[0, 1, 3]", fmt::format("{}", const_mask));
|
||||
EXPECT_EQ("[0, 1, 3]", fmt::format("{}", mask));
|
||||
EXPECT_EQ("[0, 1, 3]", fmt::format("{}", const_mask));
|
||||
EXPECT_EQ("[0, 1, 3]", fmt::format("{}", codec_mask{2}));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user