forked from boostorg/fusion
Back on track. The code is fine again.
[SVN r73695]
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
/*=============================================================================
|
/*=============================================================================
|
||||||
Copyright (c) 2001-2006 Joel de Guzman
|
Copyright (c) 2001-2011 Joel de Guzman
|
||||||
|
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
==============================================================================*/
|
==============================================================================*/
|
||||||
#if !defined(FUSION_POP_BACK_09172005_1038)
|
#if !defined(FUSION_POP_BACK_09172005_1038)
|
||||||
@ -10,22 +10,87 @@
|
|||||||
#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/sequence/intrinsic/empty.hpp>
|
||||||
|
#include <boost/fusion/iterator/iterator_adapter.hpp>
|
||||||
|
#include <boost/fusion/iterator/next.hpp>
|
||||||
|
#include <boost/mpl/minus.hpp>
|
||||||
|
#include <boost/mpl/int.hpp>
|
||||||
|
#include <boost/mpl/if.hpp>
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
|
template <typename Iterator_, bool IsLast>
|
||||||
|
struct pop_back_iterator
|
||||||
|
: iterator_adapter<
|
||||||
|
pop_back_iterator<Iterator_, IsLast>
|
||||||
|
, Iterator_>
|
||||||
|
{
|
||||||
|
typedef iterator_adapter<
|
||||||
|
pop_back_iterator<Iterator_, IsLast>
|
||||||
|
, Iterator_>
|
||||||
|
base_type;
|
||||||
|
|
||||||
|
static bool const is_last = IsLast;
|
||||||
|
|
||||||
|
pop_back_iterator(Iterator_ const& iterator_base)
|
||||||
|
: base_type(iterator_base) {}
|
||||||
|
|
||||||
|
template <bool P>
|
||||||
|
pop_back_iterator(pop_back_iterator<Iterator_, P> const& rhs)
|
||||||
|
: base_type(rhs.iterator_base) {}
|
||||||
|
|
||||||
|
template <typename BaseIterator>
|
||||||
|
struct make
|
||||||
|
{
|
||||||
|
typedef pop_back_iterator<BaseIterator, is_last> type;
|
||||||
|
|
||||||
|
static type
|
||||||
|
call(BaseIterator const& i)
|
||||||
|
{
|
||||||
|
return type(i);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename I1, typename I2>
|
||||||
|
struct equal_to
|
||||||
|
: result_of::equal_to<
|
||||||
|
typename mpl::if_c<(I1::is_last|I2::is_last)
|
||||||
|
, typename result_of::next<
|
||||||
|
typename I1::iterator_base_type>::type
|
||||||
|
, 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_<(Last::is_last?1:0)>
|
||||||
|
>::type
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
|
||||||
namespace result_of
|
namespace result_of
|
||||||
{
|
{
|
||||||
template <typename Sequence>
|
template <typename Sequence>
|
||||||
struct pop_back
|
struct pop_back
|
||||||
{
|
{
|
||||||
typedef
|
BOOST_MPL_ASSERT_NOT((result_of::empty<Sequence>));
|
||||||
iterator_range<
|
|
||||||
typename begin<Sequence>::type
|
typedef pop_back_iterator<
|
||||||
, typename prior<
|
typename begin<Sequence>::type, false>
|
||||||
typename end<Sequence>::type
|
begin_type;
|
||||||
>::type
|
|
||||||
>
|
typedef pop_back_iterator<
|
||||||
|
typename end<Sequence>::type, true>
|
||||||
|
end_type;
|
||||||
|
|
||||||
|
typedef
|
||||||
|
iterator_range<begin_type, end_type>
|
||||||
type;
|
type;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -34,8 +99,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