diff --git a/include/boost/fusion/algorithm/transformation/pop_back.hpp b/include/boost/fusion/algorithm/transformation/pop_back.hpp index 37f64326..ba68cd92 100644 --- a/include/boost/fusion/algorithm/transformation/pop_back.hpp +++ b/include/boost/fusion/algorithm/transformation/pop_back.hpp @@ -78,6 +78,51 @@ namespace boost { namespace fusion , mpl::int_<(Last::is_last?1:0)> >::type {}; + + + template + struct prior_impl + { + typedef typename Iterator::iterator_base_type base_type; + + typedef typename + result_of::prior::type + base_prior; + + typedef pop_back_iterator type; + + static type + call(Iterator const& i) + { + return type(fusion::prior(i.iterator_base)); + } + }; + + template + struct prior_impl + { + // If this is the last iterator, we'll have to double back + typedef typename Iterator::iterator_base_type base_type; + + typedef typename + result_of::prior< + typename result_of::prior::type + >::type + base_prior; + + typedef pop_back_iterator type; + + static type + call(Iterator const& i) + { + return type(fusion::prior( + fusion::prior(i.iterator_base))); + } + }; + + template + struct prior : prior_impl + {}; }; namespace result_of diff --git a/test/algorithm/pop_back.cpp b/test/algorithm/pop_back.cpp index d1055c0e..de7cc646 100644 --- a/test/algorithm/pop_back.cpp +++ b/test/algorithm/pop_back.cpp @@ -15,6 +15,9 @@ #include #include #include +#include +#include +#include #include int @@ -85,12 +88,17 @@ main() auto i1 = find(popv); auto i2 = find(pop); - assert(i1 != end(pop)); - assert(i2 != end(pop)); - assert(i1 != i2); + BOOST_TEST(i1 != end(pop)); + BOOST_TEST(i2 != end(pop)); + BOOST_TEST(i1 != i2); } #endif + { + boost::array a = { 10, 50 }; + BOOST_TEST(back(pop_back(a)) == 10); + } + return boost::report_errors(); }