Index: boost/fusion/algorithm/transformation.hpp =================================================================== --- boost/fusion/algorithm/transformation.hpp (revision 86402) +++ boost/fusion/algorithm/transformation.hpp (working copy) @@ -25,6 +25,7 @@ #include #include #include -#include +#include +#include #endif Index: boost/fusion/algorithm/transformation/flatten.hpp =================================================================== --- boost/fusion/algorithm/transformation/flatten.hpp (revision 0) +++ boost/fusion/algorithm/transformation/flatten.hpp (working copy) @@ -0,0 +1,44 @@ +/*////////////////////////////////////////////////////////////////////////////// + Copyright (c) 2013 Jamboree + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//////////////////////////////////////////////////////////////////////////////*/ +#ifndef BOOST_FUSION_ALGORITHM_FLATTEN_HPP_INCLUDED +#define BOOST_FUSION_ALGORITHM_FLATTEN_HPP_INCLUDED + + +#include +#include +#include + + +namespace boost { namespace fusion { namespace result_of +{ + template + struct flatten + { + typedef flatten_view type; + }; +}}} + +namespace boost { namespace fusion +{ + template + inline typename result_of::flatten::type + flatten(Sequence& view) + { + return flatten_view(view); + } + + template + inline typename result_of::flatten::type + flatten(Sequence const& view) + { + return flatten_view(view); + } +}} + + +#endif + Index: boost/fusion/support.hpp =================================================================== --- boost/fusion/support.hpp (revision 86402) +++ boost/fusion/support.hpp (working copy) @@ -20,5 +20,6 @@ #include #include #include +#include #endif Index: boost/fusion/support/ref.hpp =================================================================== --- boost/fusion/support/ref.hpp (revision 0) +++ boost/fusion/support/ref.hpp (working copy) @@ -0,0 +1,186 @@ +/*////////////////////////////////////////////////////////////////////////////// + Copyright (c) 2013 Jamboree + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//////////////////////////////////////////////////////////////////////////////*/ +#ifndef BOOST_FUSION_SUPPORT_REF_HPP_INCLUDED +#define BOOST_FUSION_SUPPORT_REF_HPP_INCLUDED + + +#include +#include +#include + + +namespace boost { namespace fusion +{ + struct reference_wrapper_tag; +}} + +namespace boost { namespace fusion { namespace traits +{ + template + struct tag_of > + { + typedef reference_wrapper_tag type; + }; +}}} + +namespace boost { namespace fusion { namespace extension +{ + template + struct category_of_impl; + + template + struct begin_impl; + + template + struct end_impl; + + template + struct at_impl; + + template + struct value_at_impl; + + template + struct size_impl; + + template + struct at_key_impl; + + template + struct value_at_key_impl; + + template + struct has_key_impl; + + template + struct is_sequence_impl; + + template + struct is_view_impl; + + template + struct is_segmented_impl; + + template<> + struct category_of_impl + { + template + struct apply + : category_of_impl::type>:: + template apply + {}; + }; + + template<> + struct begin_impl + { + template + struct apply + : begin_impl::type>:: + template apply + {}; + }; + + template<> + struct end_impl + { + template + struct apply + : end_impl::type>:: + template apply + {}; + }; + + template<> + struct at_impl + { + template + struct apply + : at_impl::type>:: + template apply + {}; + }; + + template<> + struct value_at_impl + { + template + struct apply + : value_at_impl::type>:: + template apply + {}; + }; + + template<> + struct size_impl + { + template + struct apply + : size_impl::type>:: + template apply + {}; + }; + + template<> + struct value_at_key_impl + { + template + struct apply + : value_at_key_impl::type>:: + template apply + {}; + }; + + template<> + struct at_key_impl + { + template + struct apply + : at_key_impl::type>:: + template apply + {}; + }; + + template<> + struct has_key_impl + { + template + struct apply + : has_key_impl::type>:: + template apply + {}; + }; + + template<> + struct is_sequence_impl + { + template + struct apply + : is_sequence_impl::type>:: + template apply + {}; + }; + + template<> + struct is_view_impl + : is_sequence_impl + {}; + + template<> + struct is_segmented_impl + { + template + struct apply + : is_segmented_impl::type>:: + template apply + {}; + }; +}}} + + +#endif + Index: boost/fusion/view.hpp =================================================================== --- boost/fusion/view.hpp (revision 86402) +++ boost/fusion/view.hpp (working copy) @@ -15,5 +15,6 @@ #include #include #include +#include #endif Index: boost/fusion/view/flatten_view/flatten_view.hpp =================================================================== --- boost/fusion/view/flatten_view/flatten_view.hpp (revision 0) +++ boost/fusion/view/flatten_view/flatten_view.hpp (working copy) @@ -0,0 +1,127 @@ +/*////////////////////////////////////////////////////////////////////////////// + Copyright (c) 2013 Jamboree + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//////////////////////////////////////////////////////////////////////////////*/ +#ifndef BOOST_FUSION_FLATTEN_VIEW_HPP_INCLUDED +#define BOOST_FUSION_FLATTEN_VIEW_HPP_INCLUDED + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace boost { namespace fusion +{ + struct forward_traversal_tag; + struct flatten_view_tag; + + template + struct flatten_view + : sequence_base > + { + typedef flatten_view_tag fusion_tag; + 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::type first_type; + typedef typename result_of::end::type last_type; + + explicit flatten_view(Sequence& seq) + : seq(seq) + {} + + first_type first() const { return fusion::begin(seq); } + last_type last() const { return fusion::end(seq); } + + typename mpl::if_, Sequence, Sequence&>::type seq; + }; +}} + +namespace boost { namespace fusion { namespace extension +{ + template<> + struct begin_impl + { + template + 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 + seek_descent; + + typedef typename seek_descent::type type; + + static inline + type call(Sequence& seq) + { + return seek_descent::apply(root_iterator(), seq.first()); + } + }; + }; + + template<> + struct end_impl + { + template + struct apply + { + typedef typename Sequence::last_type last_type; + + typedef typename + result_of::end< + mpl::single_view< + typename Sequence::sequence_type> >::type + type; + + static inline + type call(Sequence&) + { + return type(); + } + }; + }; + + template<> + struct size_impl + { + template + struct apply + : result_of::distance + < + typename result_of::begin::type + , typename result_of::end::type + > + {}; + }; + + template<> + struct empty_impl + { + template + struct apply + : result_of::empty + {}; + }; +}}} + + +#endif Index: boost/fusion/view/flatten_view/flatten_view_iterator.hpp =================================================================== --- boost/fusion/view/flatten_view/flatten_view_iterator.hpp (revision 0) +++ boost/fusion/view/flatten_view/flatten_view_iterator.hpp (working copy) @@ -0,0 +1,199 @@ +/*////////////////////////////////////////////////////////////////////////////// + Copyright (c) 2013 Jamboree + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//////////////////////////////////////////////////////////////////////////////*/ +#ifndef BOOST_FUSION_FLATTEN_VIEW_ITERATOR_HPP_INCLUDED +#define BOOST_FUSION_FLATTEN_VIEW_ITERATOR_HPP_INCLUDED + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace boost { namespace fusion +{ + struct forward_traversal_tag; + struct flatten_view_iterator_tag; + + template + struct flatten_view_iterator + : iterator_base > + { + typedef flatten_view_iterator_tag fusion_tag; + typedef forward_traversal_tag category; + + typedef convert_iterator first_converter; + typedef typename first_converter::type first_type; + typedef Base base_type; + + flatten_view_iterator(First const& first, Base const& base) + : first(first), base(base) + {} + + first_type first; + base_type base; + }; +}} + +namespace boost { namespace fusion { namespace detail +{ + template + struct make_descent_cons + { + typedef cons type; + + static inline type apply(Iterator const& it) + { + return type(it); + } + }; + + template + struct make_descent_cons::type> >::type> + { + // we use 'value_of' above for convenience, assuming the value won't be reference, + // while we must use the regular 'deref' here for const issues... + typedef typename + remove_reference::type>::type + sub_sequence; + + typedef typename + result_of::begin::type + sub_begin; + + typedef cons::type> type; + + static inline type apply(Iterator const& it) + { + return type(it, make_descent_cons::apply( + fusion::begin(*it))); + } + }; + + template + struct build_flatten_view_iterator; + + template + struct build_flatten_view_iterator, Base> + { + typedef flatten_view_iterator type; + + static inline type apply(cons const& cons, Base const& base) + { + return type(cons.car, base); + } + }; + + template + struct build_flatten_view_iterator, Base> + { + typedef flatten_view_iterator next_base; + typedef build_flatten_view_iterator next; + typedef typename next::type type; + + static inline type apply(cons const& cons, Base const& base) + { + return next::apply(cons.cdr, next_base(cons.car, base)); + } + }; + + template + struct seek_descent + { + typedef make_descent_cons make_descent_cons_; + typedef typename make_descent_cons_::type cons_type; + typedef + build_flatten_view_iterator + build_flatten_view_iterator_; + typedef typename build_flatten_view_iterator_::type type; + + static inline type apply(Base const& base, Iterator const& it) + { + return build_flatten_view_iterator_::apply( + make_descent_cons_::apply(it), base); + } + }; + + template + struct seek_descent::type>::type> >::type> + { + typedef typename result_of::next::type type; + + static inline type apply(Base const& base, Iterator const&) + { + return fusion::next(base); + } + }; +}}} + +namespace boost { namespace fusion { namespace extension +{ + template<> + struct next_impl + { + template + struct apply + { + typedef typename Iterator::first_type first_type; + typedef typename Iterator::base_type base_type; + typedef typename result_of::next::type next_type; + + typedef detail::seek_descent seek_descent; + typedef typename seek_descent::type type; + + static inline + type call(Iterator const& it) + { + return seek_descent::apply(it.base, fusion::next(it.first)); + } + }; + }; + + template<> + struct deref_impl + { + template + struct apply + { + typedef typename + result_of::deref::type + type; + + static inline + type call(Iterator const& it) + { + return *it.first; + } + }; + }; + + template<> + struct value_of_impl + { + template + struct apply + { + typedef typename + result_of::value_of::type + type; + }; + }; +}}} + + +#endif + Index: boost/fusion/view/flatten_view.hpp =================================================================== --- boost/fusion/view/flatten_view.hpp (revision 0) +++ boost/fusion/view/flatten_view.hpp (working copy) @@ -0,0 +1,15 @@ +/*////////////////////////////////////////////////////////////////////////////// + Copyright (c) 2013 Jamboree + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//////////////////////////////////////////////////////////////////////////////*/ +#ifndef BOOST_FUSION_SEQUENCE_FLATTEN_VIEW_HPP_INCLUDED +#define BOOST_FUSION_SEQUENCE_FLATTEN_VIEW_HPP_INCLUDED + + +#include +#include + + +#endif Index: boost/fusion/view/flatten_view/flatten_view.hpp =================================================================== --- boost/fusion/view/flatten_view/flatten_view.hpp (revision 0) +++ boost/fusion/view/flatten_view/flatten_view.hpp (working copy) @@ -0,0 +1,127 @@ +/*////////////////////////////////////////////////////////////////////////////// + Copyright (c) 2013 Jamboree + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//////////////////////////////////////////////////////////////////////////////*/ +#ifndef BOOST_FUSION_FLATTEN_VIEW_HPP_INCLUDED +#define BOOST_FUSION_FLATTEN_VIEW_HPP_INCLUDED + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace boost { namespace fusion +{ + struct forward_traversal_tag; + struct flatten_view_tag; + + template + struct flatten_view + : sequence_base > + { + typedef flatten_view_tag fusion_tag; + 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::type first_type; + typedef typename result_of::end::type last_type; + + explicit flatten_view(Sequence& seq) + : seq(seq) + {} + + first_type first() const { return fusion::begin(seq); } + last_type last() const { return fusion::end(seq); } + + typename mpl::if_, Sequence, Sequence&>::type seq; + }; +}} + +namespace boost { namespace fusion { namespace extension +{ + template<> + struct begin_impl + { + template + 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 + seek_descent; + + typedef typename seek_descent::type type; + + static inline + type call(Sequence& seq) + { + return seek_descent::apply(root_iterator(), seq.first()); + } + }; + }; + + template<> + struct end_impl + { + template + struct apply + { + typedef typename Sequence::last_type last_type; + + typedef typename + result_of::end< + mpl::single_view< + typename Sequence::sequence_type> >::type + type; + + static inline + type call(Sequence&) + { + return type(); + } + }; + }; + + template<> + struct size_impl + { + template + struct apply + : result_of::distance + < + typename result_of::begin::type + , typename result_of::end::type + > + {}; + }; + + template<> + struct empty_impl + { + template + struct apply + : result_of::empty + {}; + }; +}}} + + +#endif Index: boost/fusion/view/flatten_view/flatten_view_iterator.hpp =================================================================== --- boost/fusion/view/flatten_view/flatten_view_iterator.hpp (revision 0) +++ boost/fusion/view/flatten_view/flatten_view_iterator.hpp (working copy) @@ -0,0 +1,199 @@ +/*////////////////////////////////////////////////////////////////////////////// + Copyright (c) 2013 Jamboree + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//////////////////////////////////////////////////////////////////////////////*/ +#ifndef BOOST_FUSION_FLATTEN_VIEW_ITERATOR_HPP_INCLUDED +#define BOOST_FUSION_FLATTEN_VIEW_ITERATOR_HPP_INCLUDED + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace boost { namespace fusion +{ + struct forward_traversal_tag; + struct flatten_view_iterator_tag; + + template + struct flatten_view_iterator + : iterator_base > + { + typedef flatten_view_iterator_tag fusion_tag; + typedef forward_traversal_tag category; + + typedef convert_iterator first_converter; + typedef typename first_converter::type first_type; + typedef Base base_type; + + flatten_view_iterator(First const& first, Base const& base) + : first(first), base(base) + {} + + first_type first; + base_type base; + }; +}} + +namespace boost { namespace fusion { namespace detail +{ + template + struct make_descent_cons + { + typedef cons type; + + static inline type apply(Iterator const& it) + { + return type(it); + } + }; + + template + struct make_descent_cons::type> >::type> + { + // we use 'value_of' above for convenience, assuming the value won't be reference, + // while we must use the regular 'deref' here for const issues... + typedef typename + remove_reference::type>::type + sub_sequence; + + typedef typename + result_of::begin::type + sub_begin; + + typedef cons::type> type; + + static inline type apply(Iterator const& it) + { + return type(it, make_descent_cons::apply( + fusion::begin(*it))); + } + }; + + template + struct build_flatten_view_iterator; + + template + struct build_flatten_view_iterator, Base> + { + typedef flatten_view_iterator type; + + static inline type apply(cons const& cons, Base const& base) + { + return type(cons.car, base); + } + }; + + template + struct build_flatten_view_iterator, Base> + { + typedef flatten_view_iterator next_base; + typedef build_flatten_view_iterator next; + typedef typename next::type type; + + static inline type apply(cons const& cons, Base const& base) + { + return next::apply(cons.cdr, next_base(cons.car, base)); + } + }; + + template + struct seek_descent + { + typedef make_descent_cons make_descent_cons_; + typedef typename make_descent_cons_::type cons_type; + typedef + build_flatten_view_iterator + build_flatten_view_iterator_; + typedef typename build_flatten_view_iterator_::type type; + + static inline type apply(Base const& base, Iterator const& it) + { + return build_flatten_view_iterator_::apply( + make_descent_cons_::apply(it), base); + } + }; + + template + struct seek_descent::type>::type> >::type> + { + typedef typename result_of::next::type type; + + static inline type apply(Base const& base, Iterator const&) + { + return fusion::next(base); + } + }; +}}} + +namespace boost { namespace fusion { namespace extension +{ + template<> + struct next_impl + { + template + struct apply + { + typedef typename Iterator::first_type first_type; + typedef typename Iterator::base_type base_type; + typedef typename result_of::next::type next_type; + + typedef detail::seek_descent seek_descent; + typedef typename seek_descent::type type; + + static inline + type call(Iterator const& it) + { + return seek_descent::apply(it.base, fusion::next(it.first)); + } + }; + }; + + template<> + struct deref_impl + { + template + struct apply + { + typedef typename + result_of::deref::type + type; + + static inline + type call(Iterator const& it) + { + return *it.first; + } + }; + }; + + template<> + struct value_of_impl + { + template + struct apply + { + typedef typename + result_of::value_of::type + type; + }; + }; +}}} + + +#endif + Index: libs/fusion/doc/algorithm.qbk =================================================================== --- libs/fusion/doc/algorithm.qbk (revision 86403) +++ libs/fusion/doc/algorithm.qbk (working copy) @@ -1841,8 +1841,52 @@ [endsect] +[section flatten] + +[heading Description] +Returns a new sequence without nested sequences. + +[heading Synopsis] + template< + typename Sequence + > + typename __result_of_flatten__::type flatten(Sequence& seq); + + template< + typename Sequence + > + typename __result_of_flatten__::type flatten(Sequence const& seq); + +[table Parameters + [[Parameter][Requirement][Description]] + [[`seq`][A model of __forward_sequence__][Operation's argument]] +] + +[heading Expression Semantics] + __flatten__(seq); + +[*Return type]: + +* A model of __forward_sequence__. + +[*Semantics]: Returns a new sequence containing all the leaf elements of `seq`. + +[heading Complexity] +Constant. Returns a view which is lazily evaluated. + +[heading Header] + + #include + #include + +[heading Example] + const __vector__, int> vec(1, 2, __make_vector__(3, 4), 5); + assert(__flatten__(vec) == __make_vector__(1, 2, 3, 4, 5))); + [endsect] +[endsect] + [section Metafunctions] [section filter] @@ -2633,8 +2677,46 @@ [endsect] +[section flatten] + +[heading Description] +Returns the result type of __flatten__, given the input sequence type. + +[heading Synopsis] + template< + typename Sequence + > + struct flatten + { + typedef __unspecified__ type; + }; + +[table Parameters + [[Parameter][Requirement][Description]] + [[`Sequence`][A model of __forward_sequence__][Operation's argument]] +] + +[heading Expression Semantics] + __result_of_flatten__::type + +[*Return type]: + +* A model of __forward_sequence__. + +[*Semantics]: Returns a sequence with all the leaf elements of `Sequence`. + +[heading Complexity] +Constant. + +[heading Header] + + #include + #include + [endsect] [endsect] [endsect] + +[endsect] Index: libs/fusion/doc/fusion.qbk =================================================================== --- libs/fusion/doc/fusion.qbk (revision 86403) +++ libs/fusion/doc/fusion.qbk (working copy) @@ -288,6 +288,8 @@ [def __result_of_push_back__ [link fusion.algorithm.transformation.metafunctions.push_back `result_of::push_back`]] [def __push_front__ [link fusion.algorithm.transformation.functions.push_front `push_front`]] [def __result_of_push_front__ [link fusion.algorithm.transformation.metafunctions.push_front `result_of::push_front`]] +[def __flatten__ [link fusion.algorithm.transformation.functions.flatten `flatten`]] +[def __result_of_flatten__ [link fusion.algorithm.transformation.metafunctions.flatten `result_of::flatten`]] [def __tr1_tuple_pair__ [link fusion.tuple.pairs `TR1 and std::pair`]] [def __tuple_get__ [link fusion.tuple.class_template_tuple.element_access `get`]] Index: libs/fusion/test/algorithm/flatten.cpp =================================================================== --- libs/fusion/test/algorithm/flatten.cpp (revision 0) +++ libs/fusion/test/algorithm/flatten.cpp (working copy) @@ -0,0 +1,57 @@ +/*////////////////////////////////////////////////////////////////////////////// + Copyright (c) 2013 Jamboree + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//////////////////////////////////////////////////////////////////////////////*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +int main() +{ + using namespace boost::fusion; + + { + typedef vector, int> sequence_type; + sequence_type seq(1, 2, make_vector(3, 4), 5); + + BOOST_TEST((boost::fusion::size(flatten(seq)) == 5)); + } + + { + typedef vector, int> sequence_type; + sequence_type seq(1, 2, make_vector(3, 4), 5); + std::cout << flatten(seq) << std::endl; + BOOST_TEST((flatten(seq) == make_vector(1, 2, 3, 4, 5))); + } + + { + std::cout << flatten(make_vector(1, 2, make_vector(3, 4), 5)) << std::endl; + BOOST_TEST((flatten(make_vector(1, 2, make_vector(3, 4), 5)) == make_vector(1, 2, 3, 4, 5))); + } + + { + typedef vector, int> sequence_type; + sequence_type seq; + result_of::flatten::type flat(flatten(seq)); + copy(make_vector(1, 2, 3, 4, 5), flat); + std::cout << seq << std::endl; + BOOST_TEST((seq == make_vector(1, 2, make_vector(3, 4), 5))); + } + + return boost::report_errors(); +} + Index: libs/fusion/test/Jamfile =================================================================== --- libs/fusion/test/Jamfile (revision 86403) +++ libs/fusion/test/Jamfile (working copy) @@ -54,6 +54,7 @@ [ run algorithm/zip.cpp : : : : ] [ run algorithm/zip2.cpp : : : : ] [ run algorithm/zip_ignore.cpp : : : : ] + [ run algorithm/flatten.cpp : : : : ] [ run sequence/as_list.cpp : : : : ] [ run sequence/as_map.cpp : : : : ] @@ -151,6 +152,7 @@ [ run sequence/define_assoc_tpl_struct.cpp : : : : ] [ run sequence/std_tuple_iterator.cpp : : : : ] [ run sequence/ref_vector.cpp : : : : ] + [ run sequence/flatten_view.cpp : : : : ] [ run functional/fused.cpp : : : : ] [ run functional/fused_function_object.cpp : : : : ] Index: libs/fusion/test/sequence/flatten_view.cpp =================================================================== --- libs/fusion/test/sequence/flatten_view.cpp (revision 0) +++ libs/fusion/test/sequence/flatten_view.cpp (working copy) @@ -0,0 +1,56 @@ +/*////////////////////////////////////////////////////////////////////////////// + Copyright (c) 2013 Jamboree + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//////////////////////////////////////////////////////////////////////////////*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +int main() +{ + using namespace boost::fusion; + + { + typedef vector, int> sequence_type; + sequence_type seq(1, 2, make_vector(3, 4), 5); + flatten_view flatten(seq); + + BOOST_TEST((boost::fusion::size(flatten) == 5)); + BOOST_TEST((boost::fusion::distance(boost::fusion::begin(flatten), boost::fusion::end(flatten)) == 5)); + } + + { + typedef vector, int> sequence_type; + sequence_type seq(1, 2, make_vector(3, 4), 5); + flatten_view flatten(seq); + std::cout << flatten << std::endl; + BOOST_TEST((flatten == make_vector(1, 2, 3, 4, 5))); + BOOST_TEST((*advance_c<2>(boost::fusion::begin(flatten)) == 3)); + } + + { + typedef vector, int> sequence_type; + sequence_type seq; + flatten_view flatten(seq); + copy(make_vector(1, 2, 3, 4, 5), flatten); + std::cout << seq << std::endl; + BOOST_TEST((seq == make_vector(1, 2, make_vector(3, 4), 5))); + } + + return boost::report_errors(); +} +