]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/array/test/array1.cpp
1 /* simple example for using class array<>
3 * (C) Copyright Nicolai M. Josuttis 2001.
4 * Distributed under the Boost Software License, Version 1.0. (See
5 * accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
9 * 20 Jan 2001 - Removed boolalpha use since stock GCC doesn't support it
14 #include <boost/array.hpp>
18 // define special type name
19 typedef boost::array
<float,6> Array
;
21 // create and initialize an array
25 for (unsigned i
=1; i
<a
.size(); ++i
) {
29 // use some common STL container operations
30 std::cout
<< "size: " << a
.size() << std::endl
;
31 std::cout
<< "empty: " << (a
.empty() ? "true" : "false") << std::endl
;
32 std::cout
<< "max_size: " << a
.max_size() << std::endl
;
33 std::cout
<< "front: " << a
.front() << std::endl
;
34 std::cout
<< "back: " << a
.back() << std::endl
;
35 std::cout
<< "elems: ";
37 // iterate through all elements
38 for (Array::const_iterator pos
=a
.begin(); pos
<a
.end(); ++pos
) {
39 std::cout
<< *pos
<< ' ';
41 std::cout
<< std::endl
;
43 // check copy constructor and assignment operator
48 std::cout
<< "copy construction and copy assignment are OK"
52 std::cout
<< "copy construction and copy assignment FAILED"
56 return 0; // makes Visual-C++ compiler happy