forked from boostorg/fusion
revert the implementation to previous version, but changed it such that prior is not used. used advance instead which is ok for forward iterators.
[SVN r73686]
This commit is contained in:
@ -10,75 +10,22 @@
|
|||||||
#include <boost/fusion/view/iterator_range/iterator_range.hpp>
|
#include <boost/fusion/view/iterator_range/iterator_range.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||||
|
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
#include <boost/fusion/sequence/intrinsic/empty.hpp>
|
||||||
#include <boost/fusion/iterator/iterator_adapter.hpp>
|
#include <boost/fusion/iterator/advance.hpp>
|
||||||
#include <boost/fusion/iterator/next.hpp>
|
|
||||||
#include <boost/mpl/minus.hpp>
|
|
||||||
#include <boost/mpl/int.hpp>
|
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
template <typename Iterator_>
|
|
||||||
struct pop_back_iterator
|
|
||||||
: iterator_adapter<
|
|
||||||
pop_back_iterator<Iterator_>
|
|
||||||
, Iterator_>
|
|
||||||
{
|
|
||||||
typedef iterator_adapter<
|
|
||||||
pop_back_iterator<Iterator_>
|
|
||||||
, Iterator_>
|
|
||||||
base_type;
|
|
||||||
|
|
||||||
pop_back_iterator(Iterator_ const& iterator_base)
|
|
||||||
: base_type(iterator_base) {}
|
|
||||||
|
|
||||||
template <typename BaseIterator>
|
|
||||||
struct make
|
|
||||||
{
|
|
||||||
typedef pop_back_iterator<BaseIterator> type;
|
|
||||||
|
|
||||||
static type
|
|
||||||
call(BaseIterator const& i)
|
|
||||||
{
|
|
||||||
return type(i);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename I1, typename I2>
|
|
||||||
struct equal_to
|
|
||||||
: result_of::equal_to<
|
|
||||||
typename result_of::next<
|
|
||||||
typename I1::iterator_base_type>::type
|
|
||||||
, typename I2::iterator_base_type
|
|
||||||
>
|
|
||||||
{};
|
|
||||||
|
|
||||||
template <typename First, typename Last>
|
|
||||||
struct distance
|
|
||||||
: mpl::minus<
|
|
||||||
typename result_of::distance<
|
|
||||||
typename First::iterator_base_type
|
|
||||||
, typename Last::iterator_base_type
|
|
||||||
>::type
|
|
||||||
, mpl::int_<1>
|
|
||||||
>::type
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace result_of
|
namespace result_of
|
||||||
{
|
{
|
||||||
template <typename Sequence>
|
template <typename Sequence>
|
||||||
struct pop_back
|
struct pop_back
|
||||||
{
|
{
|
||||||
BOOST_MPL_ASSERT_NOT((result_of::empty<Sequence>));
|
static int const size = size<Sequence>::value;
|
||||||
|
BOOST_STATIC_ASSERT(size > 0);
|
||||||
typedef pop_back_iterator<
|
typedef typename begin<Sequence>::type begin_type;
|
||||||
typename begin<Sequence>::type>
|
typedef mpl::int_<size-1> end_index;
|
||||||
begin_type;
|
typedef typename advance<begin_type, end_index>::type end_type;
|
||||||
|
|
||||||
typedef pop_back_iterator<
|
|
||||||
typename end<Sequence>::type>
|
|
||||||
end_type;
|
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
iterator_range<begin_type, end_type>
|
iterator_range<begin_type, end_type>
|
||||||
@ -90,15 +37,12 @@ namespace boost { namespace fusion
|
|||||||
inline typename result_of::pop_back<Sequence const>::type
|
inline typename result_of::pop_back<Sequence const>::type
|
||||||
pop_back(Sequence const& seq)
|
pop_back(Sequence const& seq)
|
||||||
{
|
{
|
||||||
typedef result_of::pop_back<Sequence const> comp;
|
typedef typename
|
||||||
typedef typename comp::begin_type begin_type;
|
result_of::pop_back<Sequence const>::end_index
|
||||||
typedef typename comp::end_type end_type;
|
end_index;
|
||||||
typedef typename comp::type result;
|
|
||||||
|
|
||||||
return result(
|
typedef typename result_of::pop_back<Sequence const>::type result;
|
||||||
begin_type(fusion::begin(seq))
|
return result(fusion::begin(seq), fusion::advance<end_index>(fusion::begin(seq)));
|
||||||
, end_type(fusion::end(seq))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user