diff --git a/include/boost/fusion/algorithm/transformation/pop_back.hpp b/include/boost/fusion/algorithm/transformation/pop_back.hpp index 56d75028..08bc4c8d 100644 --- a/include/boost/fusion/algorithm/transformation/pop_back.hpp +++ b/include/boost/fusion/algorithm/transformation/pop_back.hpp @@ -10,75 +10,22 @@ #include #include #include +#include #include -#include -#include -#include -#include +#include namespace boost { namespace fusion { - template - struct pop_back_iterator - : iterator_adapter< - pop_back_iterator - , Iterator_> - { - typedef iterator_adapter< - pop_back_iterator - , Iterator_> - base_type; - - pop_back_iterator(Iterator_ const& iterator_base) - : base_type(iterator_base) {} - - template - struct make - { - typedef pop_back_iterator type; - - static type - call(BaseIterator const& i) - { - return type(i); - } - }; - - template - struct equal_to - : result_of::equal_to< - typename result_of::next< - typename I1::iterator_base_type>::type - , typename I2::iterator_base_type - > - {}; - - template - 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 { template struct pop_back { - BOOST_MPL_ASSERT_NOT((result_of::empty)); - - typedef pop_back_iterator< - typename begin::type> - begin_type; - - typedef pop_back_iterator< - typename end::type> - end_type; + static int const size = size::value; + BOOST_STATIC_ASSERT(size > 0); + typedef typename begin::type begin_type; + typedef mpl::int_ end_index; + typedef typename advance::type end_type; typedef iterator_range @@ -90,15 +37,12 @@ namespace boost { namespace fusion inline typename result_of::pop_back::type pop_back(Sequence const& seq) { - typedef result_of::pop_back comp; - typedef typename comp::begin_type begin_type; - typedef typename comp::end_type end_type; - typedef typename comp::type result; + typedef typename + result_of::pop_back::end_index + end_index; - return result( - begin_type(fusion::begin(seq)) - , end_type(fusion::end(seq)) - ); + typedef typename result_of::pop_back::type result; + return result(fusion::begin(seq), fusion::advance(fusion::begin(seq))); } }}