From 1c60bd4e64316e25b77f668f2cab8edd614464cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rimas=20Misevi=C4=8Dius?= Date: Mon, 10 Apr 2017 11:38:58 +0300 Subject: [PATCH] Use more appropriate istreambuf_iterator in the streaming.cc example Used in the example std::istream_iterator skips whitespace and thus a parser can produce unexpected reult, e.g.: Input: [{"x":"test space","y":20}] Output: "testspace",20 std::istreambuf_iterator does not skip whitespace, so is more appropriate: Output: "test space",20 More info: http://en.cppreference.com/w/cpp/iterator/istream_iterator (see "Notes" section). --- examples/streaming.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/streaming.cc b/examples/streaming.cc index 1baf75a..52a7db2 100644 --- a/examples/streaming.cc +++ b/examples/streaming.cc @@ -64,7 +64,7 @@ int main(void) { root_context ctx; std::string err; - picojson::_parse(ctx, std::istream_iterator(std::cin), std::istream_iterator(), &err); + picojson::_parse(ctx, std::istreambuf_iterator(std::cin), std::istreambuf_iterator(), &err); if (!err.empty()) { std::cerr << err << std::endl;