Update contrib.
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)
8 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
13 #include <boost/array.hpp>
16 #include "std_log_result.h"
17 #define LOG_FILENAME_LINE __FILE__, __LINE__
20 void print_elements (const T& x);
24 std_log(LOG_FILENAME_LINE,"[Test Case for array3]");
26 // create array of four seasons
27 boost::array<std::string,4> seasons = {
28 { "spring", "summer", "autumn", "winter" }
31 // copy and change order
32 boost::array<std::string,4> seasons_orig = seasons;
33 for (unsigned i=seasons.size()-1; i>0; --i) {
34 std::swap(seasons.at(i),seasons.at((i+1)%seasons.size()));
37 std::cout << "one way: ";
38 print_elements(seasons);
41 std::cout << "other way: ";
42 std::swap(seasons,seasons_orig);
43 print_elements(seasons);
45 // try reverse iterators
46 std::cout << "reverse: ";
47 for (boost::array<std::string,4>::reverse_iterator pos
48 =seasons.rbegin(); pos<seasons.rend(); ++pos) {
49 std::cout << " " << *pos;
51 std::cout << std::endl;
53 if (seasons[3]!= "winter")
55 if (seasons[2] != "autumn")
57 if (seasons[1] != "summer")
59 if (seasons[0] != "spring")
64 std_log(LOG_FILENAME_LINE,"Result : Failed");
68 std_log(LOG_FILENAME_LINE,"Result : Passed");
70 testResultXml("array3");
73 return 0; // makes Visual-C++ compiler happy
77 void print_elements (const T& x)
79 for (unsigned i=0; i<x.size(); ++i) {
80 std::cout << " " << x[i];
82 std::cout << std::endl;