Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71202 - in trunk: boost/spirit/home/support libs/spirit/example/qi
From: hartmut.kaiser_at_[hidden]
Date: 2011-04-12 10:52:15


Author: hkaiser
Date: 2011-04-12 10:52:14 EDT (Tue, 12 Apr 2011)
New Revision: 71202
URL: http://svn.boost.org/trac/boost/changeset/71202

Log:
Spirit: fixing the unescaped_string example
Text files modified:
   trunk/boost/spirit/home/support/attributes.hpp | 23 ++++++++++++++++++++++-
   trunk/boost/spirit/home/support/container.hpp | 6 ++++++
   trunk/libs/spirit/example/qi/unescaped_string.cpp | 2 +-
   3 files changed, 29 insertions(+), 2 deletions(-)

Modified: trunk/boost/spirit/home/support/attributes.hpp
==============================================================================
--- trunk/boost/spirit/home/support/attributes.hpp (original)
+++ trunk/boost/spirit/home/support/attributes.hpp 2011-04-12 10:52:14 EDT (Tue, 12 Apr 2011)
@@ -174,9 +174,30 @@
     struct is_weak_substitute<T, optional<Expected> >
       : is_weak_substitute<T, Expected> {};
 
+#define BOOST_SPIRIT_IS_WEAK_SUBSTITUTE(z, N, _) \
+ is_weak_substitute<BOOST_PP_CAT(T, N), Expected>::type::value && \
+ /***/
+
+ // make sure unused variant parameters do not affect the outcome
+ template <typename Expected>
+ struct is_weak_substitute<boost::detail::variant::void_, Expected>
+ : mpl::true_
+ {};
+
+ template <BOOST_VARIANT_ENUM_PARAMS(typename T), typename Expected>
+ struct is_weak_substitute<
+ boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, Expected>
+ : mpl::bool_<BOOST_PP_REPEAT(BOOST_VARIANT_LIMIT_TYPES
+ , BOOST_SPIRIT_IS_WEAK_SUBSTITUTE, _) true>
+ {};
+
+#undef BOOST_SPIRIT_IS_WEAK_SUBSTITUTE
+
     template <typename T>
     struct is_weak_substitute<T, T
- , typename enable_if<not_is_optional<T> >::type>
+ , typename enable_if<
+ mpl::and_<not_is_optional<T>, not_is_variant<T> >
+ >::type>
       : mpl::true_ {};
 
     ///////////////////////////////////////////////////////////////////////////

Modified: trunk/boost/spirit/home/support/container.hpp
==============================================================================
--- trunk/boost/spirit/home/support/container.hpp (original)
+++ trunk/boost/spirit/home/support/container.hpp 2011-04-12 10:52:14 EDT (Tue, 12 Apr 2011)
@@ -63,6 +63,12 @@
         is_container<BOOST_PP_CAT(T, N)>::value || \
     /***/
 
+ // make sure unused variant parameters do not affect the outcome
+ template <>
+ struct is_container<boost::detail::variant::void_>
+ : mpl::false_
+ {};
+
     template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
     struct is_container<variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
        : mpl::bool_<BOOST_PP_REPEAT(BOOST_VARIANT_LIMIT_TYPES

Modified: trunk/libs/spirit/example/qi/unescaped_string.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/unescaped_string.cpp (original)
+++ trunk/libs/spirit/example/qi/unescaped_string.cpp 2011-04-12 10:52:14 EDT (Tue, 12 Apr 2011)
@@ -24,7 +24,7 @@
                           ("\\r", '\r')("\\t", '\t')("\\v", '\v')("\\\\", '\\')
                           ("\\\'", '\'')("\\\"", '\"')
                 ;
-
+
             unesc_str = qi::lit(qi::_r1)
>> *(unesc_char | qi::alnum | "\\x" >> qi::hex)
>> qi::lit(qi::_r1)


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