Update contrib.
1 /* simple 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)
8 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
12 #include <boost/array.hpp>
14 #include "std_log_result.h"
15 #define LOG_FILENAME_LINE __FILE__, __LINE__
19 void test_static_size (const T& cont)
21 int tmp[T::static_size];
22 for (unsigned i=0; i<T::static_size; ++i) {
23 tmp[i] = int(cont[i]);
25 for (unsigned j=0; j<T::static_size; ++j) {
26 std::cout << tmp[j] << ' ';
28 std::cout << std::endl;
33 std_log(LOG_FILENAME_LINE,"[Test Case for array5]");
34 // define special type name
35 typedef boost::array<float,6> Array;
37 // create and initialize an array
38 const Array a = { { 42.42 } };
40 // use some common STL container operations
41 std::cout << "static_size: " << a.size() << std::endl;
42 std::cout << "size: " << a.size() << std::endl;
43 // Can't use std::boolalpha because it isn't portable
44 std::cout << "empty: " << (a.empty()? "true" : "false") << std::endl;
45 std::cout << "max_size: " << a.max_size() << std::endl;
46 std::cout << "front: " << a.front() << std::endl;
47 std::cout << "back: " << a.back() << std::endl;
48 std::cout << "[0]: " << a[0] << std::endl;
49 std::cout << "elems: ";
51 // iterate through all elements
52 for (Array::const_iterator pos=a.begin(); pos<a.end(); ++pos) {
53 std::cout << *pos << ' ';
55 std::cout << std::endl;
58 // check copy constructor and assignment operator
63 std::cout << "copy construction and copy assignment are OK"
65 std_log(LOG_FILENAME_LINE,"Result : Passed");
68 std::cout << "copy construction and copy assignment are BROKEN"
70 std_log(LOG_FILENAME_LINE,"Result : Failed");
74 typedef boost::array<double,6> DArray;
75 typedef boost::array<int,6> IArray;
76 IArray ia = { { 1, 2, 3, 4, 5, 6 } } ; // extra braces silence GCC warning
81 testResultXml("array5");
85 return 0; // makes Visual-C++ compiler happy