diff options
Diffstat (limited to 'boost/spirit/home/karma/stream/stream.hpp')
-rw-r--r-- | boost/spirit/home/karma/stream/stream.hpp | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/boost/spirit/home/karma/stream/stream.hpp b/boost/spirit/home/karma/stream/stream.hpp index d1cd45638e..1b679a8aab 100644 --- a/boost/spirit/home/karma/stream/stream.hpp +++ b/boost/spirit/home/karma/stream/stream.hpp @@ -142,12 +142,15 @@ namespace boost { namespace spirit { namespace karma // 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 karma::delimit_out(sink, d); // always do post-delimiting - return false; + if (!ostr.good()) + 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 @@ namespace boost { namespace spirit { namespace karma // 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 @@ -192,11 +197,11 @@ namespace boost { namespace spirit { namespace karma static bool generate(OutputIterator&, Context&, Delimiter const&, unused_type) { - // It is not possible (doesn't make sense) to use stream generators - // without providing any attribute, as the generator doesn't 'know' + // It is not possible (doesn't make sense) to use stream generators + // without providing any attribute, as the generator doesn't 'know' // what to output. The following assertion fires if this situation // is detected in your code. - BOOST_SPIRIT_ASSERT_MSG(false, stream_not_usable_without_attribute, ()); + BOOST_SPIRIT_ASSERT_FAIL(OutputIterator, stream_not_usable_without_attribute, ()); return false; } @@ -260,13 +265,16 @@ namespace boost { namespace spirit { namespace karma 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 karma::delimit_out(sink, d); // always do post-delimiting - return false; + if (!ostr.good()) + return false; + } + + return karma::delimit_out(sink, d); // always do post-delimiting } template <typename Context> |