From 052b3db77fef930439fa6421b5cc897d22da6ca0 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Wed, 9 Jun 2010 17:45:24 +0000 Subject: [PATCH] Make reading a tuple work with std::noskipws. Fixes #1920 [SVN r62678] --- include/boost/tuple/tuple_io.hpp | 4 ++++ test/io_test.cpp | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/include/boost/tuple/tuple_io.hpp b/include/boost/tuple/tuple_io.hpp index 10cdb1c..06a2339 100644 --- a/include/boost/tuple/tuple_io.hpp +++ b/include/boost/tuple/tuple_io.hpp @@ -384,6 +384,8 @@ extract_and_check_delimiter( if (is.good() && c!=d) { is.setstate(std::ios::failbit); } + } else { + is >> std::ws; } return is; } @@ -478,6 +480,8 @@ extract_and_check_delimiter( if (is.good() && c!=d) { is.setstate(std::ios::failbit); } + } else { + is >> std::ws; } return is; } diff --git a/test/io_test.cpp b/test/io_test.cpp index cf6dfb0..95babe3 100644 --- a/test/io_test.cpp +++ b/test/io_test.cpp @@ -120,6 +120,13 @@ int test_main(int argc, char * argv[] ) { is3 >> set_close(']'); BOOST_CHECK(bool(is3 >> ti2)); + // Make sure that whitespace between elements + // is skipped. + useThisIStringStream is4("(100 200 300)"); + + BOOST_CHECK(bool(is4 >> std::noskipws >> ti1)); + BOOST_CHECK(ti1 == make_tuple(100, 200, 300)); + // Note that strings are problematic: // writing a tuple on a stream and reading it back doesn't work in // general. If this is wanted, some kind of a parseable string class