First public contribution.
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
13 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
17 #include <boost/array.hpp>
20 #include "std_log_result.h"
21 #define LOG_FILENAME_LINE __FILE__, __LINE__
26 std_log(LOG_FILENAME_LINE,"[Test Case for array1]");
27 // define special type name
28 typedef boost::array<float,6> Array;
30 // create and initialize an array
34 for (unsigned i=1; i<a.size(); ++i) {
38 // use some common STL container operations
39 std::cout << "size: " << a.size() << std::endl;
40 std::cout << "empty: " << (a.empty() ? "true" : "false") << std::endl;
41 std::cout << "max_size: " << a.max_size() << std::endl;
42 std::cout << "front: " << a.front() << std::endl;
43 std::cout << "back: " << a.back() << std::endl;
44 std::cout << "elems: ";
46 // iterate through all elements
47 for (Array::const_iterator pos=a.begin(); pos<a.end(); ++pos) {
48 std::cout << *pos << ' ';
50 std::cout << std::endl;
52 // check copy constructor and assignment operator
57 std::cout << "copy construction and copy assignment are OK"
59 std_log(LOG_FILENAME_LINE,"Result : Passed");
62 std::cout << "copy construction and copy assignment FAILED"
64 std_log(LOG_FILENAME_LINE,"Result : Failed");
67 testResultXml("array1");
69 return 0; // makes Visual-C++ compiler happy