mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-19 11:14:41 +00:00
parent
ccea338070
commit
e60ff504ea
@ -490,7 +490,7 @@ struct range_formatter<
|
||||
auto out = ctx.out();
|
||||
auto it = detail::range_begin(range);
|
||||
auto end = detail::range_end(range);
|
||||
if (is_debug) return write_debug_string(out, it, end);
|
||||
if (is_debug) return write_debug_string(out, std::move(it), end);
|
||||
|
||||
out = detail::copy<Char>(opening_bracket_, out);
|
||||
int i = 0;
|
||||
|
@ -752,17 +752,17 @@ TEST(ranges_test, std_istream_iterator_join) {
|
||||
EXPECT_EQ("1, 2, 3, 4, 5", fmt::format("{}", fmt::join(first, last, ", ")));
|
||||
}
|
||||
|
||||
TEST(ranges_test, movable_only_istream_iter_join) {
|
||||
// Mirrors C++20 std::ranges::basic_istream_view::iterator.
|
||||
struct noncopyable_istream_iterator : std::istream_iterator<int> {
|
||||
explicit noncopyable_istream_iterator(std::istringstream& iss)
|
||||
: std::istream_iterator<int>{iss} {}
|
||||
// Mirrors C++20 std::ranges::basic_istream_view::iterator.
|
||||
struct noncopyable_istream_iterator : std::istream_iterator<int> {
|
||||
using base = std::istream_iterator<int>;
|
||||
explicit noncopyable_istream_iterator(std::istringstream& iss) : base{iss} {}
|
||||
noncopyable_istream_iterator(const noncopyable_istream_iterator&) = delete;
|
||||
noncopyable_istream_iterator(noncopyable_istream_iterator&&) = default;
|
||||
};
|
||||
static_assert(
|
||||
!std::is_copy_constructible<noncopyable_istream_iterator>::value, "");
|
||||
};
|
||||
static_assert(!std::is_copy_constructible<noncopyable_istream_iterator>::value,
|
||||
"");
|
||||
|
||||
TEST(ranges_test, movable_only_istream_iter_join) {
|
||||
auto&& iss = std::istringstream("1 2 3 4 5");
|
||||
auto first = noncopyable_istream_iterator(iss);
|
||||
auto last = std::istream_iterator<int>();
|
||||
@ -770,6 +770,18 @@ TEST(ranges_test, movable_only_istream_iter_join) {
|
||||
fmt::format("{}", fmt::join(std::move(first), last, ", ")));
|
||||
}
|
||||
|
||||
struct movable_iter_range {
|
||||
std::istringstream iss{"1 2 3 4 5"};
|
||||
noncopyable_istream_iterator begin() {
|
||||
return noncopyable_istream_iterator{iss};
|
||||
}
|
||||
std::istream_iterator<int> end() { return {}; }
|
||||
};
|
||||
|
||||
TEST(ranges_test, movable_only_istream_iter_join2) {
|
||||
EXPECT_EQ("[1, 2, 3, 4, 5]", fmt::format("{}", movable_iter_range{}));
|
||||
}
|
||||
|
||||
struct not_range {
|
||||
void begin() const {}
|
||||
void end() const {}
|
||||
|
Loading…
Reference in New Issue
Block a user