summaryrefslogtreecommitdiff
path: root/boost/fusion/view/flatten_view
diff options
context:
space:
mode:
Diffstat (limited to 'boost/fusion/view/flatten_view')
-rw-r--r--boost/fusion/view/flatten_view/flatten_view.hpp26
-rw-r--r--boost/fusion/view/flatten_view/flatten_view_iterator.hpp61
2 files changed, 56 insertions, 31 deletions
diff --git a/boost/fusion/view/flatten_view/flatten_view.hpp b/boost/fusion/view/flatten_view/flatten_view.hpp
index aa47240771..8e40158d1c 100644
--- a/boost/fusion/view/flatten_view/flatten_view.hpp
+++ b/boost/fusion/view/flatten_view/flatten_view.hpp
@@ -8,6 +8,7 @@
#define BOOST_FUSION_FLATTEN_VIEW_HPP_INCLUDED
+#include <boost/fusion/support/config.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/single_view.hpp>
#include <boost/fusion/support/detail/access.hpp>
@@ -23,7 +24,7 @@ namespace boost { namespace fusion
{
struct forward_traversal_tag;
struct flatten_view_tag;
-
+
template <typename Sequence>
struct flatten_view
: sequence_base<flatten_view<Sequence> >
@@ -32,18 +33,21 @@ namespace boost { namespace fusion
typedef fusion_sequence_tag tag; // this gets picked up by MPL
typedef mpl::true_ is_view;
typedef forward_traversal_tag category;
-
+
typedef Sequence sequence_type;
typedef typename result_of::begin<Sequence>::type first_type;
typedef typename result_of::end<Sequence>::type last_type;
-
+
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
explicit flatten_view(Sequence& seq)
: seq(seq)
{}
-
+
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
first_type first() const { return fusion::begin(seq); }
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
last_type last() const { return fusion::end(seq); }
-
+
typename mpl::if_<traits::is_view<Sequence>, Sequence, Sequence&>::type seq;
};
}}
@@ -57,19 +61,20 @@ namespace boost { namespace fusion { namespace extension
struct apply
{
typedef typename Sequence::first_type first_type;
-
+
typedef typename
result_of::begin<
mpl::single_view<
typename Sequence::sequence_type> >::type
root_iterator;
-
+
typedef
detail::seek_descent<root_iterator, first_type>
seek_descent;
-
+
typedef typename seek_descent::type type;
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static inline
type call(Sequence& seq)
{
@@ -77,7 +82,7 @@ namespace boost { namespace fusion { namespace extension
}
};
};
-
+
template<>
struct end_impl<flatten_view_tag>
{
@@ -85,13 +90,14 @@ namespace boost { namespace fusion { namespace extension
struct apply
{
typedef typename Sequence::last_type last_type;
-
+
typedef typename
result_of::end<
mpl::single_view<
typename Sequence::sequence_type> >::type
type;
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static inline
type call(Sequence&)
{
diff --git a/boost/fusion/view/flatten_view/flatten_view_iterator.hpp b/boost/fusion/view/flatten_view/flatten_view_iterator.hpp
index dfe613ac84..1ecf692822 100644
--- a/boost/fusion/view/flatten_view/flatten_view_iterator.hpp
+++ b/boost/fusion/view/flatten_view/flatten_view_iterator.hpp
@@ -8,6 +8,7 @@
#define BOOST_FUSION_FLATTEN_VIEW_ITERATOR_HPP_INCLUDED
+#include <boost/fusion/support/config.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/type_traits/remove_reference.hpp>
@@ -23,22 +24,23 @@ namespace boost { namespace fusion
{
struct forward_traversal_tag;
struct flatten_view_iterator_tag;
-
+
template<class First, class Base>
struct flatten_view_iterator
: iterator_base<flatten_view_iterator<First, Base> >
{
typedef flatten_view_iterator_tag fusion_tag;
typedef forward_traversal_tag category;
-
+
typedef convert_iterator<First> first_converter;
typedef typename first_converter::type first_type;
typedef Base base_type;
-
+
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
flatten_view_iterator(First const& first, Base const& base)
: first(first), base(base)
{}
-
+
first_type first;
base_type base;
};
@@ -50,13 +52,14 @@ namespace boost { namespace fusion { namespace detail
struct make_descent_cons
{
typedef cons<Iterator> type;
-
+
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static inline type apply(Iterator const& it)
{
return type(it);
}
};
-
+
template<class Iterator>
struct make_descent_cons<Iterator,
typename enable_if<traits::is_sequence<
@@ -67,20 +70,21 @@ namespace boost { namespace fusion { namespace detail
typedef typename
remove_reference<typename result_of::deref<Iterator>::type>::type
sub_sequence;
-
+
typedef typename
result_of::begin<sub_sequence>::type
sub_begin;
-
+
typedef cons<Iterator, typename make_descent_cons<sub_begin>::type> type;
-
+
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static inline type apply(Iterator const& it)
{
return type(it, make_descent_cons<sub_begin>::apply(
fusion::begin(*it)));
}
};
-
+
template<class Cons, class Base>
struct build_flatten_view_iterator;
@@ -88,26 +92,28 @@ namespace boost { namespace fusion { namespace detail
struct build_flatten_view_iterator<cons<Car>, Base>
{
typedef flatten_view_iterator<Car, Base> type;
-
+
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static inline type apply(cons<Car> const& cons, Base const& base)
{
return type(cons.car, base);
}
};
-
+
template<class Car, class Cdr, class Base>
struct build_flatten_view_iterator<cons<Car, Cdr>, Base>
{
typedef flatten_view_iterator<Car, Base> next_base;
typedef build_flatten_view_iterator<Cdr, next_base> next;
typedef typename next::type type;
-
+
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static inline type apply(cons<Car, Cdr> const& cons, Base const& base)
{
return next::apply(cons.cdr, next_base(cons.car, base));
}
};
-
+
template<class Base, class Iterator, class = void>
struct seek_descent
{
@@ -117,14 +123,15 @@ namespace boost { namespace fusion { namespace detail
build_flatten_view_iterator<cons_type, Base>
build_flatten_view_iterator_;
typedef typename build_flatten_view_iterator_::type type;
-
+
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static inline type apply(Base const& base, Iterator const& it)
{
return build_flatten_view_iterator_::apply(
make_descent_cons_::apply(it), base);
}
};
-
+
template<class Base, class Iterator>
struct seek_descent<Base, Iterator,
typename enable_if<
@@ -132,7 +139,8 @@ namespace boost { namespace fusion { namespace detail
typename result_of::value_of<Base>::type>::type> >::type>
{
typedef typename result_of::next<Base>::type type;
-
+
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static inline type apply(Base const& base, Iterator const&)
{
return fusion::next(base);
@@ -151,10 +159,11 @@ namespace boost { namespace fusion { namespace extension
typedef typename Iterator::first_type first_type;
typedef typename Iterator::base_type base_type;
typedef typename result_of::next<first_type>::type next_type;
-
+
typedef detail::seek_descent<base_type, next_type> seek_descent;
typedef typename seek_descent::type type;
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static inline
type call(Iterator const& it)
{
@@ -162,7 +171,7 @@ namespace boost { namespace fusion { namespace extension
}
};
};
-
+
template<>
struct deref_impl<flatten_view_iterator_tag>
{
@@ -173,6 +182,7 @@ namespace boost { namespace fusion { namespace extension
result_of::deref<typename Iterator::first_type>::type
type;
+ BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
static inline
type call(Iterator const& it)
{
@@ -180,13 +190,13 @@ namespace boost { namespace fusion { namespace extension
}
};
};
-
+
template<>
struct value_of_impl<flatten_view_iterator_tag>
{
template<typename Iterator>
struct apply
- {
+ {
typedef typename
result_of::value_of<typename Iterator::first_type>::type
type;
@@ -194,6 +204,15 @@ namespace boost { namespace fusion { namespace extension
};
}}}
+#ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
+namespace std
+{
+ template <typename First, typename Base>
+ struct iterator_traits< ::boost::fusion::flatten_view_iterator<First, Base> >
+ { };
+}
+#endif
+
#endif