|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r77713 - trunk/boost/spirit/home/qi/detail
From: joel_at_[hidden]
Date: 2012-04-02 08:22:31
Author: djowel
Date: 2012-04-02 08:22:30 EDT (Mon, 02 Apr 2012)
New Revision: 77713
URL: http://svn.boost.org/trac/boost/changeset/77713
Log:
fix assign_to_attribute_from_iterators where Attribute is a container of iterator_range
Text files modified:
trunk/boost/spirit/home/qi/detail/assign_to.hpp | 31 ++++++++++++++++++++++++++++++-
1 files changed, 30 insertions(+), 1 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 2012-04-02 08:22:30 EDT (Mon, 02 Apr 2012)
@@ -28,11 +28,25 @@
// accept spirit's unused_type; all no-ops. Compiler optimization will
// easily strip these away.
///////////////////////////////////////////////////////////////////////////
+ namespace detail
+ {
+ template <typename T>
+ struct is_iter_range : mpl::false_ {};
+
+ template <typename I>
+ struct is_iter_range<boost::iterator_range<I> > : mpl::true_ {};
+
+ template <typename C>
+ struct is_container_of_ranges
+ : is_iter_range<typename C::value_type> {};
+ }
+
template <typename Attribute, typename Iterator, typename Enable>
struct assign_to_attribute_from_iterators
{
+ // Common case
static void
- call(Iterator const& first, Iterator const& last, Attribute& attr)
+ call(Iterator const& first, Iterator const& last, Attribute& attr, mpl::false_)
{
if (traits::is_empty(attr))
attr = Attribute(first, last);
@@ -41,6 +55,21 @@
push_back(attr, *i);
}
}
+
+ // If Attribute is a container with value_type==iterator_range<T> just push the
+ // iterator_range into it
+ static void
+ call(Iterator const& first, Iterator const& last, Attribute& attr, mpl::true_)
+ {
+ typename Attribute::value_type rng(first, last);
+ push_back(attr, rng);
+ }
+
+ static void
+ call(Iterator const& first, Iterator const& last, Attribute& attr)
+ {
+ call(first, last, attr, detail::is_container_of_ranges<Attribute>());
+ }
};
template <typename Attribute, typename Iterator>
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