Ticket #5236: t.cc

File t.cc, 631 bytes (added by Chris Jefferson, 12 years ago)

range example

Line 
1#include <boost/range/adaptor/strided.hpp>
2#include <vector>
3#include <iostream>
4#include <ostream>
5#include <algorithm>
6
7template<typename It>
8It Prev1(It i)
9{
10 --i;
11 return i;
12}
13
14template<typename It>
15It Prev2(It i)
16{ return i - 1; }
17
18template<typename Con>
19void check_container(const Con& con)
20{
21 std::cout << std::distance(con.begin(), con.end()) << std::endl;
22 std::cout << std::distance(con.begin(), Prev1(con.end())) << std::endl;
23 std::cout << std::distance(con.begin(), Prev2(con.end())) << std::endl;
24}
25
26int main(void)
27{
28 std::vector<int> v;
29 v.push_back(1);
30 check_container(v | boost::adaptors::strided(2));
31}