mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-02 22:34:31 +02:00
insert_range empty sequences bug fix
[SVN r22336]
This commit is contained in:
@@ -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<Pos,typename Iterator::next>
|
||||
, fold_backward< Range, Sequence, push_front<_,_> >
|
||||
, identity<Sequence>
|
||||
>::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<Pos, typename end<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;
|
||||
};
|
||||
};
|
||||
|
@@ -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<range>::type::value == 10);
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user