insert_range empty sequences bug fix

[SVN r22336]
This commit is contained in:
Aleksey Gurtovoy
2004-02-20 11:27:22 +00:00
parent 1bf488e87c
commit 1eb8c2ee69
2 changed files with 28 additions and 30 deletions

View File

@@ -17,12 +17,11 @@
#ifndef BOOST_MPL_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED #ifndef BOOST_MPL_AUX_INSERT_RANGE_IMPL_HPP_INCLUDED
#define 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/copy_backward.hpp"
#include "boost/mpl/fold_backward.hpp"
#include "boost/mpl/clear.hpp" #include "boost/mpl/clear.hpp"
#include "boost/mpl/push_front.hpp" #include "boost/mpl/push_front.hpp"
#include "boost/mpl/identity.hpp" #include "boost/mpl/iterator_range.hpp"
#include "boost/mpl/apply_if.hpp" #include "boost/mpl/begin_end.hpp"
#include "boost/mpl/aux_/void_spec.hpp" #include "boost/mpl/aux_/void_spec.hpp"
#include "boost/mpl/aux_/iter_push_front.hpp" #include "boost/mpl/aux_/iter_push_front.hpp"
#include "boost/mpl/aux_/traits_lambda_spec.hpp" #include "boost/mpl/aux_/traits_lambda_spec.hpp"
@@ -35,29 +34,6 @@ namespace mpl {
// specializing either the |insert_range_traits| or the primary // specializing either the |insert_range_traits| or the primary
// |insert_range| template // |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<Pos,typename Iterator::next>
, fold_backward< Range, Sequence, push_front<_,_> >
, identity<Sequence>
>::type
, Iterator
>::type type;
};
};
} // namespace aux
template< typename Tag > template< typename Tag >
struct insert_range_traits struct insert_range_traits
@@ -69,10 +45,22 @@ struct insert_range_traits
> >
struct algorithm struct algorithm
{ {
typedef typename iter_fold_backward< typedef typename copy_backward<
Sequence iterator_range<Pos, typename end<Sequence>::type>
, typename clear<Sequence>::type , typename clear<Sequence>::type
, aux::iter_range_inserter<Pos,Range> , push_front<_,_>
>::type first_part_;
typedef typename copy_backward<
Range
, first_part_
, push_front<_,_>
>::type second_part_;
typedef typename copy_backward<
iterator_range<typename begin<Sequence>::type,Pos>
, second_part_
, push_front<_,_>
>::type type; >::type type;
}; };
}; };

View File

@@ -17,6 +17,7 @@
#include "boost/mpl/insert_range.hpp" #include "boost/mpl/insert_range.hpp"
#include "boost/mpl/find.hpp" #include "boost/mpl/find.hpp"
#include "boost/mpl/list_c.hpp" #include "boost/mpl/list_c.hpp"
#include "boost/mpl/list.hpp"
#include "boost/mpl/size.hpp" #include "boost/mpl/size.hpp"
#include "boost/mpl/range_c.hpp" #include "boost/mpl/range_c.hpp"
#include "boost/mpl/equal.hpp" #include "boost/mpl/equal.hpp"
@@ -32,5 +33,14 @@ int main()
BOOST_STATIC_ASSERT(mpl::size<range>::type::value == 10); BOOST_STATIC_ASSERT(mpl::size<range>::type::value == 10);
BOOST_STATIC_ASSERT((mpl::equal< range,mpl::range_c<int,0,10> >::type::value)); BOOST_STATIC_ASSERT((mpl::equal< range,mpl::range_c<int,0,10> >::type::value));
typedef mpl::insert_range<
mpl::list0<>,
mpl::end< mpl::list0<> >::type,
mpl::list<int>
>::type result2;
BOOST_STATIC_ASSERT((mpl::size<result2>::type::value == 1));
return 0; return 0;
} }