summaryrefslogtreecommitdiff
path: root/boost/spirit/home/qi
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2013-08-26 08:15:55 -0400
committerAnas Nashif <anas.nashif@intel.com>2013-08-26 08:15:55 -0400
commitbb4dd8289b351fae6b55e303f189127a394a1edd (patch)
tree77c9c35a31b1459dd7988c2448e797d142530c41 /boost/spirit/home/qi
parent1a78a62555be32868418fe52f8e330c9d0f95d5a (diff)
downloadboost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.gz
boost-bb4dd8289b351fae6b55e303f189127a394a1edd.tar.bz2
boost-bb4dd8289b351fae6b55e303f189127a394a1edd.zip
Imported Upstream version 1.51.0upstream/1.51.0
Diffstat (limited to 'boost/spirit/home/qi')
-rw-r--r--boost/spirit/home/qi/detail/assign_to.hpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/boost/spirit/home/qi/detail/assign_to.hpp b/boost/spirit/home/qi/detail/assign_to.hpp
index a94010ca91..38142bf1b3 100644
--- a/boost/spirit/home/qi/detail/assign_to.hpp
+++ b/boost/spirit/home/qi/detail/assign_to.hpp
@@ -28,11 +28,25 @@ namespace boost { namespace spirit { namespace traits
// 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 @@ namespace boost { namespace spirit { namespace traits
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>