From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/array/test/array5.cpp | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/boost/libs/array/test/array5.cpp (limited to 'src/boost/libs/array/test/array5.cpp') diff --git a/src/boost/libs/array/test/array5.cpp b/src/boost/libs/array/test/array5.cpp new file mode 100644 index 00000000..23156b9c --- /dev/null +++ b/src/boost/libs/array/test/array5.cpp @@ -0,0 +1,72 @@ +/* simple example for using class array<> + * (C) Copyright Nicolai M. Josuttis 2001. + * Distributed under the Boost Software License, Version 1.0. (See + * accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ + +#include +#include + +template +void test_static_size (const T& cont) +{ + int tmp[T::static_size]; + for (unsigned i=0; i Array; + + // create and initialize an array + const Array a = { { 42.42f } }; + + // use some common STL container operations + std::cout << "static_size: " << a.size() << std::endl; + std::cout << "size: " << a.size() << std::endl; + // Can't use std::boolalpha because it isn't portable + std::cout << "empty: " << (a.empty()? "true" : "false") << std::endl; + std::cout << "max_size: " << a.max_size() << std::endl; + std::cout << "front: " << a.front() << std::endl; + std::cout << "back: " << a.back() << std::endl; + std::cout << "[0]: " << a[0] << std::endl; + std::cout << "elems: "; + + // iterate through all elements + for (Array::const_iterator pos=a.begin(); pos DArray; + typedef boost::array IArray; + IArray ia = { { 1, 2, 3, 4, 5, 6 } } ; // extra braces silence GCC warning + DArray da; + da = ia; + da.assign(42); + + return 0; // makes Visual-C++ compiler happy +} + -- cgit v1.2.3