|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55054 - trunk/boost/spirit/home/support
From: joel_at_[hidden]
Date: 2009-07-21 03:10:26
Author: djowel
Date: 2009-07-21 03:10:25 EDT (Tue, 21 Jul 2009)
New Revision: 55054
URL: http://svn.boost.org/trac/boost/changeset/55054
Log:
fix/optimize traits::clear
Text files modified:
trunk/boost/spirit/home/support/attributes.hpp | 33 +++++++++++++++++++++------------
1 files changed, 21 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-21 03:10:25 EDT (Tue, 21 Jul 2009)
@@ -444,19 +444,15 @@
{
val.clear();
}
-
- template <typename T>
- void clear_impl(optional<T>& val, mpl::true_)
- {
- val = T();
- }
-
- template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
- void clear_impl(variant<BOOST_VARIANT_ENUM_PARAMS(T)>& val
- , mpl::true_)
+
+ struct clear_visitor : static_visitor<>
{
- val = variant<BOOST_VARIANT_ENUM_PARAMS(T)>();
- }
+ template <typename T>
+ void operator()(T& val) const
+ {
+ clear(val);
+ }
+ };
}
template <typename T>
@@ -469,6 +465,19 @@
{
}
+ template <typename T>
+ void clear(optional<T>& val)
+ {
+ if (val)
+ clear(*val);
+ }
+
+ template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
+ void clear(variant<BOOST_VARIANT_ENUM_PARAMS(T)>& var)
+ {
+ apply_visitor(detail::clear_visitor(), var);
+ }
+
}}}
#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