| 1 | #include "boost/range/adaptor/transformed.hpp"
|
|---|
| 2 | #include "boost/range/algorithm/copy.hpp"
|
|---|
| 3 | #include "boost/range/algorithm/max_element.hpp"
|
|---|
| 4 | #include <iostream>
|
|---|
| 5 | #include <vector>
|
|---|
| 6 |
|
|---|
| 7 | struct double_int
|
|---|
| 8 | {
|
|---|
| 9 | typedef int result_type;
|
|---|
| 10 | int operator()(int x) const { return x * 2; }
|
|---|
| 11 | };
|
|---|
| 12 |
|
|---|
| 13 | int main(int argc, const char* argv[])
|
|---|
| 14 | {
|
|---|
| 15 | using namespace boost::adaptors;
|
|---|
| 16 |
|
|---|
| 17 | std::vector<int> input{1,2,3,4,5,6,7,8,9,10};
|
|---|
| 18 |
|
|---|
| 19 | std::cout << *boost::max_element(input | transformed(double_int())) << std::endl;
|
|---|
| 20 |
|
|---|
| 21 | return 0;
|
|---|
| 22 | }
|
|---|