mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-21 08:12:39 +02:00
Made pop_back not use prior.
[SVN r73643]
This commit is contained in:
@ -10,22 +10,120 @@
|
|||||||
#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/iterator/prior.hpp>
|
#include <boost/fusion/iterator/iterator_facade.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_facade<
|
||||||
|
pop_back_iterator<Iterator_>
|
||||||
|
, typename Iterator_::category>
|
||||||
|
{
|
||||||
|
typedef Iterator_ base_type;
|
||||||
|
base_type base;
|
||||||
|
|
||||||
|
pop_back_iterator(base_type const& base)
|
||||||
|
: base(base) {}
|
||||||
|
|
||||||
|
template <typename I1, typename I2>
|
||||||
|
struct equal_to
|
||||||
|
: is_same<
|
||||||
|
typename result_of::next<
|
||||||
|
typename I1::base_type>::type
|
||||||
|
, typename I2::base_type
|
||||||
|
>
|
||||||
|
{};
|
||||||
|
|
||||||
|
template <typename Iterator, typename N>
|
||||||
|
struct advance
|
||||||
|
: pop_back_iterator<
|
||||||
|
typename result_of::advance<
|
||||||
|
typename Iterator::base_type, N>::type
|
||||||
|
>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename First, typename Last>
|
||||||
|
struct distance
|
||||||
|
: mpl::minus<
|
||||||
|
typename result_of::distance<
|
||||||
|
typename First::base_type
|
||||||
|
, typename Last::base_type
|
||||||
|
>::type
|
||||||
|
, mpl::int_<1>
|
||||||
|
>::type
|
||||||
|
{};
|
||||||
|
|
||||||
|
template <typename Iterator>
|
||||||
|
struct value_of
|
||||||
|
: result_of::value_of<typename Iterator::base_type> {};
|
||||||
|
|
||||||
|
template <typename Iterator>
|
||||||
|
struct deref
|
||||||
|
{
|
||||||
|
typedef typename
|
||||||
|
result_of::deref<typename Iterator::base_type>::type
|
||||||
|
type;
|
||||||
|
|
||||||
|
static type
|
||||||
|
call(Iterator const& it)
|
||||||
|
{
|
||||||
|
return fusion::deref(it.base);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Iterator>
|
||||||
|
struct next
|
||||||
|
{
|
||||||
|
typedef pop_back_iterator<
|
||||||
|
typename result_of::next<
|
||||||
|
typename Iterator::base_type
|
||||||
|
>::type>
|
||||||
|
type;
|
||||||
|
|
||||||
|
static type
|
||||||
|
call(Iterator const& i)
|
||||||
|
{
|
||||||
|
return fusion::next(i.base);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Iterator>
|
||||||
|
struct prior
|
||||||
|
{
|
||||||
|
typedef pop_back_iterator<
|
||||||
|
typename result_of::prior<
|
||||||
|
typename Iterator::base_type
|
||||||
|
>::type>
|
||||||
|
type;
|
||||||
|
|
||||||
|
static type
|
||||||
|
call(Iterator const& i)
|
||||||
|
{
|
||||||
|
return fusion::prior(i.base);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
namespace result_of
|
namespace result_of
|
||||||
{
|
{
|
||||||
template <typename Sequence>
|
template <typename Sequence>
|
||||||
struct pop_back
|
struct pop_back
|
||||||
{
|
{
|
||||||
|
typedef pop_back_iterator<
|
||||||
|
typename begin<Sequence>::type>
|
||||||
|
begin_type;
|
||||||
|
|
||||||
|
typedef pop_back_iterator<
|
||||||
|
typename end<Sequence>::type>
|
||||||
|
end_type;
|
||||||
|
|
||||||
typedef
|
typedef
|
||||||
iterator_range<
|
iterator_range<begin_type, end_type>
|
||||||
typename begin<Sequence>::type
|
|
||||||
, typename prior<
|
|
||||||
typename end<Sequence>::type
|
|
||||||
>::type
|
|
||||||
>
|
|
||||||
type;
|
type;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -34,8 +132,15 @@ 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 typename result_of::pop_back<Sequence const>::type result;
|
typedef result_of::pop_back<Sequence const> comp;
|
||||||
return result(fusion::begin(seq), fusion::prior(fusion::end(seq)));
|
typedef typename comp::begin_type begin_type;
|
||||||
|
typedef typename comp::end_type end_type;
|
||||||
|
typedef typename comp::type result;
|
||||||
|
|
||||||
|
return result(
|
||||||
|
begin_type(fusion::begin(seq))
|
||||||
|
, end_type(fusion::end(seq))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user