Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55090 - trunk/boost/spirit/home/support
From: joel_at_[hidden]
Date: 2009-07-22 16:14:12


Author: djowel
Date: 2009-07-22 16:14:12 EDT (Wed, 22 Jul 2009)
New Revision: 55090
URL: http://svn.boost.org/trac/boost/changeset/55090

Log:
fix missing include
Text files modified:
   trunk/boost/spirit/home/support/attributes.hpp | 46 +++++++++++++++++++++++++++++----------
   1 files changed, 34 insertions(+), 12 deletions(-)

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-22 16:14:12 EDT (Wed, 22 Jul 2009)
@@ -19,6 +19,7 @@
 #include <boost/fusion/include/as_vector.hpp>
 #include <boost/fusion/include/push_front.hpp>
 #include <boost/fusion/include/is_sequence.hpp>
+#include <boost/fusion/include/for_each.hpp>
 #include <boost/utility/value_init.hpp>
 #include <boost/type_traits/is_same.hpp>
 #include <boost/mpl/eval_if.hpp>
@@ -426,52 +427,73 @@
     ///////////////////////////////////////////////////////////////////////////
     // clear
     //
- // Clear data efficiently ()
+ // Clear data efficiently
     ///////////////////////////////////////////////////////////////////////////
     template <typename T>
     struct is_container;
 
     namespace detail
     {
+ // this is used by the variant and fusion sequence dispatch
+ struct clear_visitor : static_visitor<>
+ {
+ template <typename T>
+ void operator()(T& val) const
+ {
+ clear(val);
+ }
+ };
+
+ // default
         template <typename T>
- void clear_impl(T& val, mpl::false_)
+ void clear_impl2(T& val, mpl::false_)
         {
             val = T();
         }
 
+ // for fusion sequences
+ template <typename T>
+ void clear_impl2(T& val, mpl::true_)
+ {
+ fusion::for_each(val, clear_visitor());
+ }
+
+ // dispatch default or fusion sequence
+ template <typename T>
+ void clear_impl(T& val, mpl::false_)
+ {
+ clear_impl2(val, fusion::traits::is_sequence<T>());
+ }
+
+ // STL containers
         template <typename T>
         void clear_impl(T& val, mpl::true_)
         {
             val.clear();
         }
-
- struct clear_visitor : static_visitor<>
- {
- template <typename T>
- void operator()(T& val) const
- {
- clear(val);
- }
- };
     }
 
+ // main dispatch
     template <typename T>
     void clear(T& val)
     {
         detail::clear_impl(val, typename is_container<T>::type());
     }
 
+ // for unused
     inline void clear(unused_type)
     {
     }
 
+ // optionals
     template <typename T>
     void clear(optional<T>& val)
     {
         if (val)
             clear(*val);
     }
-
+
+ // variants
     template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
     void clear(variant<BOOST_VARIANT_ENUM_PARAMS(T)>& var)
     {


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