diff --git a/include/boost/io/ostream_put.hpp b/include/boost/io/ostream_put.hpp index 5ed5753..2e86ebe 100644 --- a/include/boost/io/ostream_put.hpp +++ b/include/boost/io/ostream_put.hpp @@ -46,17 +46,21 @@ class osp_guard { public: explicit osp_guard(std::basic_ostream& os) BOOST_NOEXCEPT : os_(&os) { } + ~osp_guard() BOOST_NOEXCEPT_IF(false) { if (os_) { os_->setstate(std::basic_ostream::badbit); } } + void release() BOOST_NOEXCEPT { os_ = 0; } + private: osp_guard(const osp_guard&); osp_guard& operator=(const osp_guard&); + std::basic_ostream* os_; }; diff --git a/include/boost/io/quoted.hpp b/include/boost/io/quoted.hpp index 7f67917..5effdd3 100644 --- a/include/boost/io/quoted.hpp +++ b/include/boost/io/quoted.hpp @@ -31,15 +31,14 @@ inline std::basic_ostream& operator<<(std::basic_ostream& os, const quoted_proxy& proxy) { - os << proxy.delim; + os.put(proxy.delim); for (const Char* it = proxy.string; *it; ++it) { if (*it == proxy.delim || *it == proxy.escape) { - os << proxy.escape; + os.put(proxy.escape); } - os << *it; + os.put(*it); } - os << proxy.delim; - return os; + return os.put(proxy.delim); } template @@ -48,18 +47,16 @@ quoted_output(std::basic_ostream& os, const std::basic_string& string, Char escape, Char delim) { - os << delim; - typename std::basic_string::const_iterator end = string.end(); + os.put(delim); for (typename std::basic_string::const_iterator it = string.begin(); it != end; ++it) { + Alloc>::const_iterator it = string.begin(), end = string.end(); + it != end; ++it) { if (*it == delim || *it == escape) { - os << escape; + os.put(escape); } - os << *it; + os.put(*it); } - os << delim; - return os; + return os.put(delim); } template @@ -86,21 +83,20 @@ inline std::basic_istream& operator>>(std::basic_istream& is, const quoted_proxy*, Char>& proxy) { - proxy.string->clear(); Char ch; - if (!(is >> ch).good()) { + if (!(is >> ch)) { return is; } if (ch != proxy.delim) { is.unget(); - is >> *proxy.string; - return is; + return is >> *proxy.string; } { boost::io::ios_flags_saver ifs(is); std::noskipws(is); - while ((is >> ch).good() && ch != proxy.delim) { - if (ch == proxy.escape && !(is >> ch).good()) { + proxy.string->clear(); + while ((is >> ch) && ch != proxy.delim) { + if (ch == proxy.escape && !(is >> ch)) { break; } proxy.string->push_back(ch);