]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/local_function/test/transform_seq.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / local_function / test / transform_seq.cpp
1
2 // Copyright (C) 2009-2012 Lorenzo Caminiti
3 // Distributed under the Boost Software License, Version 1.0
4 // (see accompanying file LICENSE_1_0.txt or a copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 // Home at http://www.boost.org/libs/local_function
7
8 #include <boost/local_function.hpp>
9 #include <boost/detail/lightweight_test.hpp>
10 #include <algorithm>
11 #include <vector>
12
13 int main(void) {
14 int offset = 5;
15 std::vector<int> v;
16 std::vector<int> w;
17
18 for(int i = 1; i <= 2; ++i) v.push_back(i * 10);
19 BOOST_TEST(v[0] == 10); BOOST_TEST(v[1] == 20);
20 w.resize(v.size());
21
22 int BOOST_LOCAL_FUNCTION( (const bind& offset) (int i) ) {
23 return ++i + offset;
24 } BOOST_LOCAL_FUNCTION_NAME(inc)
25
26 std::transform(v.begin(), v.end(), w.begin(), inc);
27 BOOST_TEST(w[0] == 16); BOOST_TEST(w[1] == 26);
28
29 int BOOST_LOCAL_FUNCTION( (bind& inc) (int i) (int j) ) {
30 return inc(i + j);
31 } BOOST_LOCAL_FUNCTION_NAME(inc_sum)
32
33 offset = 0;
34 std::transform(v.begin(), v.end(), w.begin(), v.begin(), inc_sum);
35 BOOST_TEST(v[0] == 27); BOOST_TEST(v[1] == 47);
36
37 return boost::report_errors();
38 }
39