$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r72110 - in trunk/boost/spirit/home/karma: auxiliary stream
From: hartmut.kaiser_at_[hidden]
Date: 2011-05-22 21:54:49
Author: hkaiser
Date: 2011-05-22 21:54:48 EDT (Sun, 22 May 2011)
New Revision: 72110
URL: http://svn.boost.org/trac/boost/changeset/72110
Log:
Spirit: fixing karma::lazy
Text files modified: 
   trunk/boost/spirit/home/karma/auxiliary/lazy.hpp |    43 ++++++++++++++++++++++++++++++++++++--- 
   trunk/boost/spirit/home/karma/stream/stream.hpp  |     4 +-                                      
   2 files changed, 41 insertions(+), 6 deletions(-)
Modified: trunk/boost/spirit/home/karma/auxiliary/lazy.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/auxiliary/lazy.hpp	(original)
+++ trunk/boost/spirit/home/karma/auxiliary/lazy.hpp	2011-05-22 21:54:48 EDT (Sun, 22 May 2011)
@@ -44,6 +44,40 @@
     using spirit::lazy;
     typedef modify<karma::domain> karma_modify;
 
+    namespace detail
+    {
+        template <typename Generator, typename OutputIterator, typename Context
+          , typename Delimiter, typename Attribute>
+        bool lazy_generate_impl(Generator const& g, OutputIterator& sink
+          , Context& context, Delimiter const& delim
+          , Attribute const& attr, mpl::false_)
+        {
+            return g.generate(sink, context, delim, attr);
+        }
+
+        template <typename Generator, typename OutputIterator, typename Context
+          , typename Delimiter, typename Attribute>
+        bool lazy_generate_impl(Generator const& g, OutputIterator& sink
+          , Context& context, Delimiter const& delim
+          , Attribute const& attr, mpl::true_)
+        {
+            // If DeducedAuto is false (semantic actions is present), the
+            // component's attribute is unused.
+            return g.generate(sink, context, delim, unused);
+        }
+
+        template <typename Generator, typename OutputIterator, typename Context
+          , typename Delimiter, typename Attribute>
+        bool lazy_generate_impl_main(Generator const& g, OutputIterator& sink
+          , Context& context, Delimiter const& delim, Attribute const& attr)
+        {
+            // If DeducedAuto is true (no semantic action), we pass the parser's
+            // attribute on to the component.
+            typedef typename traits::has_semantic_action<Generator>::type auto_rule;
+            return lazy_generate_impl(g, sink, context, delim, attr, auto_rule());
+        }
+    }
+
     template <typename Function, typename Modifiers>
     struct lazy_generator : generator<lazy_generator<Function, Modifiers> >
     {
@@ -86,9 +120,10 @@
         bool generate(OutputIterator& sink, Context& context, 
             Delimiter const& d, Attribute const& attr) const
         {
-            return compile<karma::domain>(func(unused, context)
+            return detail::lazy_generate_impl_main(
+                compile<karma::domain>(func(unused, context)
               , karma_modify()(tag::lazy_eval(), modifiers))
-                .generate(sink, context, d, attr);
+              , sink, context, d, attr);
         }
 
         template <typename Context>
@@ -162,11 +197,11 @@
         bool generate(OutputIterator& sink, Context& ctx, Delimiter const& d
           , Attribute const& attr) const
         {
-            return compile<karma::domain>(
+            return detail::lazy_generate_impl_main(compile<karma::domain>(
                 proto::make_expr<proto::tag::subscript>(
                     function(unused, ctx), subject)
                   , karma_modify()(tag::lazy_eval(), modifiers))
-                .generate(sink, ctx, d, attr);
+                  , sink, ctx, d, attr);
         }
 
         template <typename Context>
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	2011-05-22 21:54:48 EDT (Sun, 22 May 2011)
@@ -229,7 +229,7 @@
             typename OutputIterator, typename Context, typename Delimiter
           , typename Attribute>
         bool generate(OutputIterator& sink, Context&, Delimiter const& d
-          , Attribute const&)
+          , Attribute const&) const
         {
             typedef karma::detail::iterator_sink<
                 OutputIterator, Char, CharEncoding, Tag
@@ -251,7 +251,7 @@
         bool generate(
             karma::detail::output_iterator<
                 karma::ostream_iterator<T1, Char, Traits>, Properties
-            >& sink, Context&, Delimiter const& d, Attribute const&)
+            >& sink, Context&, Delimiter const& d, Attribute const&) const
         {
             typedef karma::detail::output_iterator<
                 karma::ostream_iterator<T1, Char, Traits>, Properties