]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/array/test/array2.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / array / test / array2.cpp
1 /* example for using class array<>
2 * (C) Copyright Nicolai M. Josuttis 2001.
3 * Distributed under the Boost Software License, Version 1.0. (See
4 * accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
6 */
7
8 #ifndef _SCL_SECURE_NO_WARNINGS
9 // Suppress warnings from the std lib:
10 # define _SCL_SECURE_NO_WARNINGS
11 #endif
12
13 #include <algorithm>
14 #include <functional>
15 #include <boost/array.hpp>
16 #include "print.hpp"
17 using namespace std;
18
19 int main()
20 {
21 // create and initialize array
22 boost::array<int,10> a = { { 1, 2, 3, 4, 5 } };
23
24 print_elements(a);
25
26 // modify elements directly
27 for (unsigned i=0; i<a.size(); ++i) {
28 ++a[i];
29 }
30 print_elements(a);
31
32 // change order using an STL algorithm
33 reverse(a.begin(),a.end());
34 print_elements(a);
35
36 // negate elements using STL framework
37 transform(a.begin(),a.end(), // source
38 a.begin(), // destination
39 negate<int>()); // operation
40 print_elements(a);
41
42 return 0; // makes Visual-C++ compiler happy
43 }
44