language: C++ 4.7.2 (gcc-4.7.2)
date: 571 days 10 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <boost/mpl/reverse.hpp>
#include <boost/mpl/find_if.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/advance.hpp>
#include <boost/mpl/lambda.hpp>
#include <boost/mpl/vector_c.hpp>
#include <boost/mpl/find.hpp>
#include <iostream>
using namespace boost::mpl;
 
template<typename SEQ, typename pred>
struct rfind_if {
private:
  // find the element in the reversed container    
  typedef typename reverse<SEQ>::type   rev_SEQ;
  typedef typename lambda<pred>::type   expanded_pred;    
  typedef typename find_if<rev_SEQ, expanded_pred>::type   rev_iter;
  // compute the distance of the iterator
  typedef typename distance<rev_iter, typename end<rev_SEQ>::type >::type  dist;
public:
  //compute the iterator
  typedef typename advance<typename begin<SEQ>::type, typename prior<dist>::type>::type   type;
};
 
int main() {
  typedef vector_c<int, 1, 2, 3, 6, 5, 4>::type  test_vect;
  typedef find<test_vect, integral_c<int, 6> >::type  it_cur;
  typedef rfind_if<test_vect, lambda<less<_1, deref<it_cur>::type> >::type >::type  it_swap;
  std::cout << "it_swap=" << deref<it_swap>::type::value << "\n\n";
}