Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74873 - in branches/release: boost/fusion boost/fusion/algorithm/transformation libs/fusion libs/fusion/test/algorithm
From: joel_at_[hidden]
Date: 2011-10-09 22:33:14


Author: djowel
Date: 2011-10-09 22:33:13 EDT (Sun, 09 Oct 2011)
New Revision: 74873
URL: http://svn.boost.org/trac/boost/changeset/74873

Log:
Fix for ticket #6000

Properties modified:
   branches/release/boost/fusion/ (props changed)
   branches/release/libs/fusion/ (props changed)
Text files modified:
   branches/release/boost/fusion/algorithm/transformation/pop_back.hpp | 45 ++++++++++++++++++++++++++++++++++++++++
   branches/release/libs/fusion/test/algorithm/pop_back.cpp | 14 +++++++++--
   2 files changed, 56 insertions(+), 3 deletions(-)

Modified: branches/release/boost/fusion/algorithm/transformation/pop_back.hpp
==============================================================================
--- branches/release/boost/fusion/algorithm/transformation/pop_back.hpp (original)
+++ branches/release/boost/fusion/algorithm/transformation/pop_back.hpp 2011-10-09 22:33:13 EDT (Sun, 09 Oct 2011)
@@ -78,6 +78,51 @@
               , mpl::int_<(Last::is_last?1:0)>
>::type
         {};
+
+
+ template <typename Iterator, bool IsLast_>
+ struct prior_impl
+ {
+ typedef typename Iterator::iterator_base_type base_type;
+
+ typedef typename
+ result_of::prior<base_type>::type
+ base_prior;
+
+ typedef pop_back_iterator<base_prior, false> type;
+
+ static type
+ call(Iterator const& i)
+ {
+ return type(fusion::prior(i.iterator_base));
+ }
+ };
+
+ template <typename Iterator>
+ struct prior_impl<Iterator, true>
+ {
+ // 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<base_type>::type
+ >::type
+ base_prior;
+
+ typedef pop_back_iterator<base_prior, false> type;
+
+ static type
+ call(Iterator const& i)
+ {
+ return type(fusion::prior(
+ fusion::prior(i.iterator_base)));
+ }
+ };
+
+ template <typename Iterator>
+ struct prior : prior_impl<Iterator, Iterator::is_last>
+ {};
     };
 
     namespace result_of

Modified: branches/release/libs/fusion/test/algorithm/pop_back.cpp
==============================================================================
--- branches/release/libs/fusion/test/algorithm/pop_back.cpp (original)
+++ branches/release/libs/fusion/test/algorithm/pop_back.cpp 2011-10-09 22:33:13 EDT (Sun, 09 Oct 2011)
@@ -15,6 +15,9 @@
 #include <boost/fusion/algorithm/transformation/pop_back.hpp>
 #include <boost/fusion/algorithm/transformation/push_back.hpp>
 #include <boost/fusion/algorithm/query/find.hpp>
+#include <boost/fusion/include/back.hpp>
+#include <boost/fusion/include/array.hpp>
+#include <boost/array.hpp>
 #include <boost/mpl/vector_c.hpp>
 
 int
@@ -85,12 +88,17 @@
         auto i1 = find<int>(popv);
         auto i2 = find<double>(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<std::size_t, 2> a = { 10, 50 };
+ BOOST_TEST(back(pop_back(a)) == 10);
+ }
+
     return boost::report_errors();
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk