Fixing formatting of certain kinds of ranges of ranges. (#2787)

* Fixing formatting of certain kinds of ranges of ranges.

* Renaming const_range to range_type.
This commit is contained in:
Barry Revzin
2022-03-04 18:21:00 -06:00
committed by GitHub
parent 5c0d656401
commit 0cef1f819e
2 changed files with 40 additions and 21 deletions

View File

@@ -364,3 +364,18 @@ TEST(ranges_test, escape_convertible_to_string_view) {
"[\"foo\"]");
}
#endif // FMT_USE_STRING_VIEW
template <typename R> struct fmt_ref_view {
R* r;
auto begin() const -> decltype(r->begin()) { return r->begin(); }
auto end() const -> decltype(r->end()) { return r->end(); }
};
TEST(ranges_test, range_of_range_of_mixed_const) {
std::vector<std::vector<int>> v = {{1, 2, 3}, {4, 5}};
EXPECT_EQ(fmt::format("{}", v), "[[1, 2, 3], [4, 5]]");
fmt_ref_view<decltype(v)> r{&v};
EXPECT_EQ(fmt::format("{}", r), "[[1, 2, 3], [4, 5]]");
}