Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54941 - in trunk/boost/spirit/home: qi/operator support
From: joel_at_[hidden]
Date: 2009-07-14 02:45:58


Author: djowel
Date: 2009-07-14 02:45:56 EDT (Tue, 14 Jul 2009)
New Revision: 54941
URL: http://svn.boost.org/trac/boost/changeset/54941

Log:
fix lists not reseting its local value used as the left parser's attribute between matching consecutive elements of the 'list'.
Text files modified:
   trunk/boost/spirit/home/qi/operator/list.hpp | 1 +
   trunk/boost/spirit/home/support/attributes.hpp | 30 +++++++++++++++++++++++++++++-
   2 files changed, 30 insertions(+), 1 deletions(-)

Modified: trunk/boost/spirit/home/qi/operator/list.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/operator/list.hpp (original)
+++ trunk/boost/spirit/home/qi/operator/list.hpp 2009-07-14 02:45:56 EDT (Tue, 14 Jul 2009)
@@ -65,6 +65,7 @@
             if (left.parse(first, last, context, skipper, val))
             {
                 traits::push_back(attr, val);
+ traits::clear(val);
                 Iterator i = first;
                 while (right.parse(i, last, context, skipper, unused)
                  && left.parse(i, last, context, skipper, val))

Modified: trunk/boost/spirit/home/support/attributes.hpp
==============================================================================
--- trunk/boost/spirit/home/support/attributes.hpp (original)
+++ trunk/boost/spirit/home/support/attributes.hpp 2009-07-14 02:45:56 EDT (Tue, 14 Jul 2009)
@@ -422,7 +422,35 @@
     {
         typedef T type;
     };
-
+
+ ///////////////////////////////////////////////////////////////////////////
+ // clear
+ //
+ // Clear data efficiently ()
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T>
+ struct is_container;
+
+ namespace detail
+ {
+ template <typename T>
+ void clear_impl(T& val, mpl::false_)
+ {
+ val = T();
+ }
+
+ template <typename T>
+ void clear_impl(T& val, mpl::true_)
+ {
+ val.clear();
+ }
+ }
+
+ template <typename T>
+ void clear(T& val)
+ {
+ detail::clear_impl(val, is_container<T>::type());
+ }
 }}}
 
 #endif


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