|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r68687 - trunk/boost/spirit/home/qi/detail
From: hartmut.kaiser_at_[hidden]
Date: 2011-02-06 20:25:23
Author: hkaiser
Date: 2011-02-06 20:25:22 EST (Sun, 06 Feb 2011)
New Revision: 68687
URL: http://svn.boost.org/trac/boost/changeset/68687
Log:
Spirit: fixing handling for container attributes in parser sequences
Text files modified:
trunk/boost/spirit/home/qi/detail/assign_to.hpp | 24 ++++++++++++++++++++----
1 files changed, 20 insertions(+), 4 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-02-06 20:25:22 EST (Sun, 06 Feb 2011)
@@ -176,7 +176,7 @@
iterator_type;
iterator_type end = traits::end(val);
for (iterator_type i = traits::begin(val); i != end; traits::next(i))
- push_back(attr, traits::deref(i));
+ traits::push_back(attr, traits::deref(i));
}
// T is a string
@@ -184,17 +184,33 @@
static void append_to_string(Attribute& attr, Iterator begin, Iterator end)
{
for (Iterator i = begin; i != end; ++i)
- push_back(attr, *i);
+ traits::push_back(attr, *i);
}
- template <typename T_, typename Pred>
- static void call(T_ const& val, Attribute& attr, Pred, mpl::true_)
+ // 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_)
{
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_)
+ {
+ traits::push_back(attr, val);
+ }
+
+ template <typename T_, typename Pred>
+ static void call(T_ const& val, Attribute& attr, Pred, mpl::true_)
+ {
+ 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());
+ }
+
static void call(T const& val, Attribute& attr)
{
typedef typename traits::is_container<T>::type is_container;
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