diff --git a/include/boost/mpl/aux_/insert_range_impl.hpp b/include/boost/mpl/aux_/insert_range_impl.hpp index ecdef71..726dee6 100644 --- a/include/boost/mpl/aux_/insert_range_impl.hpp +++ b/include/boost/mpl/aux_/insert_range_impl.hpp @@ -17,12 +17,11 @@ #ifndef BOOST_MPL_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED #define BOOST_MPL_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED -#include "boost/mpl/iter_fold_backward.hpp" -#include "boost/mpl/fold_backward.hpp" +#include "boost/mpl/copy_backward.hpp" #include "boost/mpl/clear.hpp" #include "boost/mpl/push_front.hpp" -#include "boost/mpl/identity.hpp" -#include "boost/mpl/apply_if.hpp" +#include "boost/mpl/iterator_range.hpp" +#include "boost/mpl/begin_end.hpp" #include "boost/mpl/aux_/void_spec.hpp" #include "boost/mpl/aux_/iter_push_front.hpp" #include "boost/mpl/aux_/traits_lambda_spec.hpp" @@ -35,29 +34,6 @@ namespace mpl { // specializing either the |insert_range_traits| or the primary // |insert_range| template -namespace aux { - -template< - typename Pos - , typename Range - > -struct iter_range_inserter -{ - template< typename Sequence, typename Iterator > struct apply - { - typedef typename aux::iter_push_front< - typename apply_if< - is_same - , fold_backward< Range, Sequence, push_front<_,_> > - , identity - >::type - , Iterator - >::type type; - }; -}; - -} // namespace aux - template< typename Tag > struct insert_range_traits @@ -69,10 +45,22 @@ struct insert_range_traits > struct algorithm { - typedef typename iter_fold_backward< - Sequence + typedef typename copy_backward< + iterator_range::type> , typename clear::type - , aux::iter_range_inserter + , push_front<_,_> + >::type first_part_; + + typedef typename copy_backward< + Range + , first_part_ + , push_front<_,_> + >::type second_part_; + + typedef typename copy_backward< + iterator_range::type,Pos> + , second_part_ + , push_front<_,_> >::type type; }; }; diff --git a/test/insert_range.cpp b/test/insert_range.cpp index 066f68e..259025f 100644 --- a/test/insert_range.cpp +++ b/test/insert_range.cpp @@ -17,6 +17,7 @@ #include "boost/mpl/insert_range.hpp" #include "boost/mpl/find.hpp" #include "boost/mpl/list_c.hpp" +#include "boost/mpl/list.hpp" #include "boost/mpl/size.hpp" #include "boost/mpl/range_c.hpp" #include "boost/mpl/equal.hpp" @@ -32,5 +33,14 @@ int main() BOOST_STATIC_ASSERT(mpl::size::type::value == 10); BOOST_STATIC_ASSERT((mpl::equal< range,mpl::range_c >::type::value)); + + typedef mpl::insert_range< + mpl::list0<>, + mpl::end< mpl::list0<> >::type, + mpl::list + >::type result2; + + BOOST_STATIC_ASSERT((mpl::size::type::value == 1)); + return 0; }