Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83926 - trunk/boost/spirit/home/karma/stream
From: hartmut.kaiser_at_[hidden]
Date: 2013-04-16 08:16:40


Author: hkaiser
Date: 2013-04-16 08:16:39 EDT (Tue, 16 Apr 2013)
New Revision: 83926
URL: http://svn.boost.org/trac/boost/changeset/83926

Log:
Spirit: making sure destructor of temporary stream is called in the right places
Text files modified:
   trunk/boost/spirit/home/karma/stream/stream.hpp | 44 +++++++++++++++++++++++----------------
   1 files changed, 26 insertions(+), 18 deletions(-)

Modified: trunk/boost/spirit/home/karma/stream/stream.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/stream/stream.hpp (original)
+++ trunk/boost/spirit/home/karma/stream/stream.hpp 2013-04-16 08:16:39 EDT (Tue, 16 Apr 2013)
@@ -142,12 +142,15 @@
             // use existing operator<<()
             typedef typename attribute<Context>::type attribute_type;
 
- boost::iostreams::stream<sink_device> ostr(sink);
- ostr << traits::extract_from<attribute_type>(attr, context) << std::flush;
+ {
+ boost::iostreams::stream<sink_device> ostr(sink);
+ ostr << traits::extract_from<attribute_type>(attr, context) << std::flush;
+
+ if (!ostr.good())
+ return false;
+ }
 
- if (ostr.good())
- return karma::delimit_out(sink, d); // always do post-delimiting
- return false;
+ return karma::delimit_out(sink, d); // always do post-delimiting
         }
 
         // this is a special overload to detect if the output iterator has been
@@ -175,14 +178,16 @@
             // use existing operator<<()
             typedef typename attribute<Context>::type attribute_type;
 
- boost::iostreams::stream<sink_device> ostr(sink);
- ostr.imbue(sink.get_ostream().getloc());
- ostr << traits::extract_from<attribute_type>(attr, context)
- << std::flush;
+ {
+ boost::iostreams::stream<sink_device> ostr(sink);
+ ostr.imbue(sink.get_ostream().getloc());
+ ostr << traits::extract_from<attribute_type>(attr, context)
+ << std::flush;
+ if (!ostr.good())
+ return false;
+ }
 
- if (ostr.good())
- return karma::delimit_out(sink, d); // always do post-delimiting
- return false;
+ return karma::delimit_out(sink, d); // always do post-delimiting
         }
 
         // this any_stream has no parameter attached, it needs to have been
@@ -260,13 +265,16 @@
                 output_iterator, Char, CharEncoding, Tag
> sink_device;
 
- boost::iostreams::stream<sink_device> ostr(sink);
- ostr.imbue(sink.get_ostream().getloc());
- ostr << t_ << std::flush; // use existing operator<<()
+ {
+ boost::iostreams::stream<sink_device> ostr(sink);
+ ostr.imbue(sink.get_ostream().getloc());
+ ostr << t_ << std::flush; // use existing operator<<()
+
+ if (!ostr.good())
+ return false;
+ }
 
- if (ostr.good())
- return karma::delimit_out(sink, d); // always do post-delimiting
- return false;
+ return karma::delimit_out(sink, d); // always do post-delimiting
         }
 
         template <typename Context>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk