mirror of
				https://github.com/fmtlib/fmt.git
				synced 2025-11-03 23:51:41 +01:00 
			
		
		
		
	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:
		@@ -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]]");
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user