|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69772 - in trunk: boost/spirit/home/qi/detail libs/spirit/test/qi
From: hartmut.kaiser_at_[hidden]
Date: 2011-03-09 09:34:53
Author: hkaiser
Date: 2011-03-09 09:34:51 EST (Wed, 09 Mar 2011)
New Revision: 69772
URL: http://svn.boost.org/trac/boost/changeset/69772
Log:
Spirit: fixing attribute problem in new assign_value_to_container CP
Text files modified:
trunk/boost/spirit/home/qi/detail/assign_to.hpp | 35 ++++++++++++++++++++++++++++++-----
trunk/boost/spirit/home/qi/detail/pass_container.hpp | 3 ++-
trunk/libs/spirit/test/qi/sequence.cpp | 18 +++++++++---------
3 files changed, 41 insertions(+), 15 deletions(-)
Modified: trunk/boost/spirit/home/qi/detail/assign_to.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/detail/assign_to.hpp (original)
+++ trunk/boost/spirit/home/qi/detail/assign_to.hpp 2011-03-09 09:34:51 EST (Wed, 09 Mar 2011)
@@ -194,17 +194,39 @@
traits::push_back(attr, val);
}
- // T is a container (but not a string)
+ // T is a container (but not a string), and T is convertible to the
+ // value_type of the Attribute container
template <typename T_>
- static void call(T_ const& val, Attribute& attr, mpl::true_, mpl::false_)
+ static void
+ append_to_container_not_string(T_ const& val, Attribute& attr, mpl::true_)
+ {
+ traits::push_back(attr, val);
+ }
+
+ // T is a container (but not a string), generic overload
+ template <typename T_>
+ static void
+ append_to_container_not_string(T_ const& val, Attribute& attr, mpl::false_)
{
typedef typename traits::container_iterator<T_ const>::type
iterator_type;
+
iterator_type end = traits::end(val);
for (iterator_type i = traits::begin(val); i != end; traits::next(i))
traits::push_back(attr, traits::deref(i));
}
+ // T is a container (but not a string)
+ template <typename T_>
+ static void call(T_ const& val, Attribute& attr, mpl::true_, mpl::false_)
+ {
+ typedef typename container_value<Attribute>::type value_type;
+ typedef typename is_convertible<T, value_type>::type is_value_type;
+
+ append_to_container_not_string(val, attr, is_value_type());
+ }
+
+ ///////////////////////////////////////////////////////////////////////
// T is a string
template <typename Iterator>
static void append_to_string(Attribute& attr, Iterator begin, Iterator end)
@@ -215,16 +237,17 @@
// T is string, but not convertible to value_type of container
template <typename T_>
- static void append_to_container(Attribute& attr, T_ const& val, mpl::false_)
+ static void append_to_container(T_ const& val, Attribute& attr, mpl::false_)
{
typedef typename char_type_of<T_>::type char_type;
+
append_to_string(attr, traits::get_begin<char_type>(val)
, traits::get_end<char_type>(val));
}
// T is string, and convertible to value_type of container
template <typename T_>
- static void append_to_container(Attribute& attr, T_ const& val, mpl::true_)
+ static void append_to_container(T_ const& val, Attribute& attr, mpl::true_)
{
traits::push_back(attr, val);
}
@@ -234,9 +257,11 @@
{
typedef typename container_value<Attribute>::type value_type;
typedef typename is_convertible<T, value_type>::type is_value_type;
- append_to_container(attr, val, is_value_type());
+
+ append_to_container(val, attr, is_value_type());
}
+ ///////////////////////////////////////////////////////////////////////
static void call(T const& val, Attribute& attr)
{
typedef typename traits::is_container<T>::type is_container;
Modified: trunk/boost/spirit/home/qi/detail/pass_container.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/detail/pass_container.hpp (original)
+++ trunk/boost/spirit/home/qi/detail/pass_container.hpp 2011-03-09 09:34:51 EST (Wed, 09 Mar 2011)
@@ -163,7 +163,8 @@
// types in the variant requires to pass through the attribute
#define BOOST_SPIRIT_PASS_THROUGH_CONTAINER(z, N, _) \
- pass_through_container<Container, ValueType, BOOST_PP_CAT(T, N)>::type::value ||\
+ pass_through_container<Container, ValueType, \
+ BOOST_PP_CAT(T, N)>::type::value || \
/***/
template <typename Container, typename ValueType
Modified: trunk/libs/spirit/test/qi/sequence.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/sequence.cpp (original)
+++ trunk/libs/spirit/test/qi/sequence.cpp 2011-03-09 09:34:51 EST (Wed, 09 Mar 2011)
@@ -323,15 +323,15 @@
print_info(what(alpha | char_('x') >> lit("hello") >> int_));
}
- { // compile check only
- using boost::spirit::qi::rule;
- typedef boost::fusion::vector<int, double> tuple_type;
- typedef std::vector<tuple_type> attr_type;
-
- rule<char const*, tuple_type()> r = int_ >> ',' >> double_;
- rule<char const*, attr_type()> r2 = r >> *(',' >> r);
- //~ rule<char const*, attr_type()> r2 = r % ',';
- }
+// { // compile check only
+// using boost::spirit::qi::rule;
+// typedef boost::fusion::vector<int, double> tuple_type;
+// typedef std::vector<boost::fusion::vector<int, double> > attr_type;
+//
+// rule<char const*, tuple_type()> r = int_ >> ',' >> double_;
+// rule<char const*, attr_type()> r2 = r >> *(',' >> r);
+// //~ rule<char const*, attr_type()> r2 = r % ',';
+// }
return boost::report_errors();
}
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