SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <boost/phoenix/core.hpp> | |
| 2 | #include <boost/phoenix/function.hpp> | |
| 3 | #include <iostream> | |
| 4 | #include <string> | |
| 5 | #include <vector> | |
| 6 | #include <algorithm> | |
| 7 | ||
| 8 | template<typename T> | |
| 9 | struct Var | |
| 10 | {
| |
| 11 | void setMax(int i) {}
| |
| 12 | void setMin(int i) {}
| |
| 13 | int getMax() { return 0; }
| |
| 14 | int getMin() { return 0; }
| |
| 15 | }; | |
| 16 | ||
| 17 | namespace impl | |
| 18 | {
| |
| 19 | template <typename T1> | |
| 20 | - | void squeeze(T1 t, int i) |
| 20 | + | void squeeze(T1& t, int i) |
| 21 | {
| |
| 22 | t.first.setMax(t.second.getMax() - i); | |
| 23 | t.second.setMin(t.first.getMin() + i); | |
| 24 | } | |
| 25 | } | |
| 26 | ||
| 27 | BOOST_PHOENIX_ADAPT_FUNCTION(void, squeeze, impl::squeeze, 2) | |
| 28 | ||
| 29 | int main() | |
| 30 | {
| |
| 31 | using boost::phoenix::arg_names::_1; | |
| 32 | std::vector<std::pair<Var<int>, Var<double> > > vec; | |
| 33 | std::for_each(vec.begin(), vec.end(), squeeze(_1, 2)); | |
| 34 | } | |
| 35 | ||
| 36 | ||
| 37 | ||
| 38 |