]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/multi_array/example/subview.cpp
1 // Copyright 2002 The Trustees of Indiana University.
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 // Boost.MultiArray Library
8 // Authors: Ronald Garcia
11 // See http://www.boost.org/libs/multi_array for documentation.
14 #include "boost/multi_array.hpp"
15 #include "boost/cstdlib.hpp"
21 typedef boost::multi_array
<int,ndims
> array
;
32 const int data_size
=24;
34 array
myarray(boost::extents
[2][3][4]);
35 myarray
.assign(data
,data
+data_size
);
39 // [base,stride,bound)
40 // [0,1,2), [1,1,3), [0,2,4)
43 typedef array::index_range range
;
44 array::array_view
<ndims
>::type myview
=
45 myarray
[boost::indices
[range(0,2)][range(1,3)][range(0,4,2)]];
47 for (array::index i
= 0; i
!= 2; ++i
)
48 for (array::index j
= 0; j
!= 2; ++j
)
49 for (array::index k
= 0; k
!= 2; ++k
)
50 assert(myview
[i
][j
][k
] == myarray
[i
][j
+1][k
*2]);
52 return boost::exit_success
;