1 | #include <boost/range/adaptor/strided.hpp>
|
---|
2 | #include <vector>
|
---|
3 | #include <iostream>
|
---|
4 | #include <ostream>
|
---|
5 | #include <algorithm>
|
---|
6 |
|
---|
7 | template<typename It>
|
---|
8 | It Prev1(It i)
|
---|
9 | {
|
---|
10 | --i;
|
---|
11 | return i;
|
---|
12 | }
|
---|
13 |
|
---|
14 | template<typename It>
|
---|
15 | It Prev2(It i)
|
---|
16 | { return i - 1; }
|
---|
17 |
|
---|
18 | template<typename Con>
|
---|
19 | void 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 |
|
---|
26 | int main(void)
|
---|
27 | {
|
---|
28 | std::vector<int> v;
|
---|
29 | v.push_back(1);
|
---|
30 | check_container(v | boost::adaptors::strided(2));
|
---|
31 | }
|
---|