diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/array | |
parent | Initial commit. (diff) | |
download | ceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.tar.xz ceph-6d07fdb6bb33b1af39833b850bb6cf8af79fe293.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/array')
-rw-r--r-- | src/boost/libs/array/CMakeLists.txt | 24 | ||||
-rw-r--r-- | src/boost/libs/array/index.html | 13 | ||||
-rw-r--r-- | src/boost/libs/array/meta/libraries.json | 17 | ||||
-rw-r--r-- | src/boost/libs/array/test/Jamfile.v2 | 18 | ||||
-rw-r--r-- | src/boost/libs/array/test/array0.cpp | 89 | ||||
-rw-r--r-- | src/boost/libs/array/test/array1.cpp | 58 | ||||
-rw-r--r-- | src/boost/libs/array/test/array2.cpp | 44 | ||||
-rw-r--r-- | src/boost/libs/array/test/array3.cpp | 62 | ||||
-rw-r--r-- | src/boost/libs/array/test/array4.cpp | 43 | ||||
-rw-r--r-- | src/boost/libs/array/test/array5.cpp | 72 | ||||
-rw-r--r-- | src/boost/libs/array/test/array6.cpp | 60 | ||||
-rw-r--r-- | src/boost/libs/array/test/array7.cpp | 66 | ||||
-rw-r--r-- | src/boost/libs/array/test/array_constexpr.cpp | 39 | ||||
-rw-r--r-- | src/boost/libs/array/test/array_getfail1.cpp | 50 | ||||
-rw-r--r-- | src/boost/libs/array/test/array_getfail2.cpp | 65 | ||||
-rw-r--r-- | src/boost/libs/array/test/array_hash.cpp | 44 | ||||
-rw-r--r-- | src/boost/libs/array/test/print.hpp | 27 | ||||
-rw-r--r-- | src/boost/libs/array/test/test_cmake/CMakeLists.txt | 22 | ||||
-rw-r--r-- | src/boost/libs/array/test/test_cmake/main.cpp | 5 |
19 files changed, 818 insertions, 0 deletions
diff --git a/src/boost/libs/array/CMakeLists.txt b/src/boost/libs/array/CMakeLists.txt new file mode 100644 index 000000000..9c7c14528 --- /dev/null +++ b/src/boost/libs/array/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright 2018 Mike Dev +# 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 + +# NOTE: CMake support for Boost.Array is currently experimental at best +# and the interface is likely to change in the future + +cmake_minimum_required(VERSION 3.5) +project(boost-array LANGUAGES CXX) + +add_library(boost_array INTERFACE) +add_library(Boost::array ALIAS boost_array) + +target_include_directories(boost_array INTERFACE include) + +target_link_libraries(boost_array + INTERFACE + Boost::assert + Boost::config + Boost::core + Boost::static_assert + Boost::throw_exception +) + diff --git a/src/boost/libs/array/index.html b/src/boost/libs/array/index.html new file mode 100644 index 000000000..a9e3c343f --- /dev/null +++ b/src/boost/libs/array/index.html @@ -0,0 +1,13 @@ +<html> +<head> +<meta http-equiv="refresh" content="0; URL=../../doc/html/array.html"> +</head> +<body> +Automatic redirection failed, please go to +<a href="../../doc/html/array.html">../../doc/html/array.html</a> <hr> +<p>© Copyright Beman Dawes, 2001</p> +<p>Distributed under the Boost Software License, Version 1.0. (See accompanying +file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy +at <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p> +</body> +</html>
\ No newline at end of file diff --git a/src/boost/libs/array/meta/libraries.json b/src/boost/libs/array/meta/libraries.json new file mode 100644 index 000000000..7710ee25e --- /dev/null +++ b/src/boost/libs/array/meta/libraries.json @@ -0,0 +1,17 @@ +{ + "key": "array", + "name": "Array", + "authors": [ + "Nicolai Josuttis" + ], + "description": "STL compliant container wrapper for arrays of constant size.", + "std": [ + "tr1" + ], + "category": [ + "Containers" + ], + "maintainers": [ + "Marshall Clow <marshall -at- idio.com>" + ] +} diff --git a/src/boost/libs/array/test/Jamfile.v2 b/src/boost/libs/array/test/Jamfile.v2 new file mode 100644 index 000000000..4c29720e9 --- /dev/null +++ b/src/boost/libs/array/test/Jamfile.v2 @@ -0,0 +1,18 @@ +#~ Copyright Rene Rivera 2008 +#~ 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) + +test-suite array : + [ run array0.cpp ] + [ run array1.cpp ] + [ run array2.cpp ] + [ run array3.cpp ] + [ run array4.cpp ] + [ run array5.cpp ] + [ run array6.cpp ] + [ run array7.cpp ] +# [ run array_constexpr.cpp ] + [ compile-fail array_getfail1.cpp ] + [ compile-fail array_getfail2.cpp ] + [ run array_hash.cpp ] + ; diff --git a/src/boost/libs/array/test/array0.cpp b/src/boost/libs/array/test/array0.cpp new file mode 100644 index 000000000..af1d47bb2 --- /dev/null +++ b/src/boost/libs/array/test/array0.cpp @@ -0,0 +1,89 @@ +/* tests for using class array<> specialization for size 0 + * (C) Copyright Alisdair Meredith 2006. + * 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 <string> +#include <iostream> +#include <boost/array.hpp> + +#include <boost/core/lightweight_test_trait.hpp> + +namespace { + +template< class T > +void BadValue( const T & ) +{ + BOOST_TEST ( false ); +} + +template< class T > +void RunTests() +{ + typedef boost::array< T, 0 > test_type; + + // Test value and aggegrate initialization + test_type test_case = {}; + const boost::array< T, 0 > const_test_case = test_type(); + + test_case.fill ( T() ); + + // front/back and operator[] must compile, but calling them is undefined + // Likewise, all tests below should evaluate to false, avoiding undefined behaviour + BOOST_TEST ( test_case.empty()); + BOOST_TEST ( const_test_case.empty()); + + BOOST_TEST ( test_case.size() == 0 ); + BOOST_TEST ( const_test_case.size() == 0 ); + + // Assert requirements of TR1 6.2.2.4 + BOOST_TEST ( test_case.begin() == test_case.end()); + BOOST_TEST ( test_case.cbegin() == test_case.cend()); + BOOST_TEST ( const_test_case.begin() == const_test_case.end()); + BOOST_TEST ( const_test_case.cbegin() == const_test_case.cend()); + + BOOST_TEST ( test_case.begin() != const_test_case.begin() ); + if( test_case.data() == const_test_case.data() ) { + // Value of data is unspecified in TR1, so no requirement this test pass or fail + // However, it must compile! + } + + // Check can safely use all iterator types with std algorithms + std::for_each( test_case.begin(), test_case.end(), BadValue< T > ); + std::for_each( test_case.rbegin(), test_case.rend(), BadValue< T > ); + std::for_each( test_case.cbegin(), test_case.cend(), BadValue< T > ); + std::for_each( const_test_case.begin(), const_test_case.end(), BadValue< T > ); + std::for_each( const_test_case.rbegin(), const_test_case.rend(), BadValue< T > ); + std::for_each( const_test_case.cbegin(), const_test_case.cend(), BadValue< T > ); + + // Check swap is well formed + std::swap( test_case, test_case ); + + // Check assignment operator and overloads are well formed + test_case = const_test_case; + + // Confirm at() throws the std lib defined exception + try { + BadValue( test_case.at( 0 )); + } catch ( const std::out_of_range & ) { + } + + try { + BadValue( const_test_case.at( 0 ) ); + } catch ( const std::out_of_range & ) { + } +} + +} + +int main() +{ + RunTests< bool >(); + RunTests< void * >(); + RunTests< long double >(); + RunTests< std::string >(); + + return boost::report_errors(); +} diff --git a/src/boost/libs/array/test/array1.cpp b/src/boost/libs/array/test/array1.cpp new file mode 100644 index 000000000..740968f4e --- /dev/null +++ b/src/boost/libs/array/test/array1.cpp @@ -0,0 +1,58 @@ +/* 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) + * + * Changelog: + * 20 Jan 2001 - Removed boolalpha use since stock GCC doesn't support it + * (David Abrahams) + */ + +#include <iostream> +#include <boost/array.hpp> + +int main() +{ + // define special type name + typedef boost::array<float,6> Array; + + // create and initialize an array + Array a = { { 42 } }; + + // access elements + for (unsigned i=1; i<a.size(); ++i) { + a[i] = a[i-1]+1; + } + + // use some common STL container operations + std::cout << "size: " << a.size() << std::endl; + 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 << "elems: "; + + // iterate through all elements + for (Array::const_iterator pos=a.begin(); pos<a.end(); ++pos) { + std::cout << *pos << ' '; + } + std::cout << std::endl; + + // check copy constructor and assignment operator + Array b(a); + Array c; + c = a; + if (a==b && a==c) { + std::cout << "copy construction and copy assignment are OK" + << std::endl; + } + else { + std::cout << "copy construction and copy assignment FAILED" + << std::endl; + } + + return 0; // makes Visual-C++ compiler happy +} + diff --git a/src/boost/libs/array/test/array2.cpp b/src/boost/libs/array/test/array2.cpp new file mode 100644 index 000000000..b33e0b56b --- /dev/null +++ b/src/boost/libs/array/test/array2.cpp @@ -0,0 +1,44 @@ +/* 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) + */ + +#ifndef _SCL_SECURE_NO_WARNINGS +// Suppress warnings from the std lib: +# define _SCL_SECURE_NO_WARNINGS +#endif + +#include <algorithm> +#include <functional> +#include <boost/array.hpp> +#include "print.hpp" +using namespace std; + +int main() +{ + // create and initialize array + boost::array<int,10> a = { { 1, 2, 3, 4, 5 } }; + + print_elements(a); + + // modify elements directly + for (unsigned i=0; i<a.size(); ++i) { + ++a[i]; + } + print_elements(a); + + // change order using an STL algorithm + reverse(a.begin(),a.end()); + print_elements(a); + + // negate elements using STL framework + transform(a.begin(),a.end(), // source + a.begin(), // destination + negate<int>()); // operation + print_elements(a); + + return 0; // makes Visual-C++ compiler happy +} + diff --git a/src/boost/libs/array/test/array3.cpp b/src/boost/libs/array/test/array3.cpp new file mode 100644 index 000000000..29aacb125 --- /dev/null +++ b/src/boost/libs/array/test/array3.cpp @@ -0,0 +1,62 @@ +/* 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 <string> +#include <iostream> +#include <boost/array.hpp> + +template <class T> +void print_elements (const T& x); + +int main() +{ + // create array of four seasons + boost::array<std::string,4> seasons = { + { "spring", "summer", "autumn", "winter" } + }; + + // copy and change order + boost::array<std::string,4> seasons_orig = seasons; + for (std::size_t i=seasons.size()-1; i>0; --i) { + std::swap(seasons.at(i),seasons.at((i+1)%seasons.size())); + } + + std::cout << "one way: "; + print_elements(seasons); + + // try swap() + std::cout << "other way: "; + std::swap(seasons,seasons_orig); + print_elements(seasons); + + // try reverse iterators + std::cout << "reverse: "; + for (boost::array<std::string,4>::reverse_iterator pos + =seasons.rbegin(); pos<seasons.rend(); ++pos) { + std::cout << " " << *pos; + } + + // try constant reverse iterators + std::cout << "reverse: "; + for (boost::array<std::string,4>::const_reverse_iterator pos + =seasons.crbegin(); pos<seasons.crend(); ++pos) { + std::cout << " " << *pos; + } + std::cout << std::endl; + + return 0; // makes Visual-C++ compiler happy +} + +template <class T> +void print_elements (const T& x) +{ + for (unsigned i=0; i<x.size(); ++i) { + std::cout << " " << x[i]; + } + std::cout << std::endl; +} + diff --git a/src/boost/libs/array/test/array4.cpp b/src/boost/libs/array/test/array4.cpp new file mode 100644 index 000000000..33b98190e --- /dev/null +++ b/src/boost/libs/array/test/array4.cpp @@ -0,0 +1,43 @@ +/* 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 <algorithm> +#include <functional> +#include <string> +#include <iostream> +#include <boost/array.hpp> + +int main() +{ + // array of arrays of seasons + boost::array<boost::array<std::string,4>,2> seasons_i18n = { + { { { "spring", "summer", "autumn", "winter", } }, + { { "Fruehling", "Sommer", "Herbst", "Winter" } } + } + }; + + // for any array of seasons print seasons + for (unsigned i=0; i<seasons_i18n.size(); ++i) { + boost::array<std::string,4> seasons = seasons_i18n[i]; + for (unsigned j=0; j<seasons.size(); ++j) { + std::cout << seasons[j] << " "; + } + std::cout << std::endl; + } + + // print first element of first array + std::cout << "first element of first array: " + << seasons_i18n[0][0] << std::endl; + + // print last element of last array + std::cout << "last element of last array: " + << seasons_i18n[seasons_i18n.size()-1][seasons_i18n[0].size()-1] + << std::endl; + + return 0; // makes Visual-C++ compiler happy +} + diff --git a/src/boost/libs/array/test/array5.cpp b/src/boost/libs/array/test/array5.cpp new file mode 100644 index 000000000..23156b9cb --- /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 <iostream> +#include <boost/array.hpp> + +template <typename T> +void test_static_size (const T& cont) +{ + int tmp[T::static_size]; + for (unsigned i=0; i<T::static_size; ++i) { + tmp[i] = int(cont[i]); + } + for (unsigned j=0; j<T::static_size; ++j) { + std::cout << tmp[j] << ' '; + } + std::cout << std::endl; +} + +int main() +{ + // define special type name + typedef boost::array<float,6> 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<a.end(); ++pos) { + std::cout << *pos << ' '; + } + std::cout << std::endl; + test_static_size(a); + + // check copy constructor and assignment operator + Array b(a); + Array c; + c = a; + if (a==b && a==c) { + std::cout << "copy construction and copy assignment are OK" + << std::endl; + } + else { + std::cout << "copy construction and copy assignment are BROKEN" + << std::endl; + } + + typedef boost::array<double,6> DArray; + typedef boost::array<int,6> 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 +} + diff --git a/src/boost/libs/array/test/array6.cpp b/src/boost/libs/array/test/array6.cpp new file mode 100644 index 000000000..d2cca910c --- /dev/null +++ b/src/boost/libs/array/test/array6.cpp @@ -0,0 +1,60 @@ +/* tests for using class array<> specialization for size 0 + * (C) Copyright Alisdair Meredith 2006. + * 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 <string> +#include <iostream> +#include <boost/array.hpp> +#include <algorithm> + +#include <boost/core/lightweight_test_trait.hpp> + +namespace { + template< class T > + void RunTests() + { + typedef boost::array< T, 5 > test_type; + typedef T arr[5]; + test_type test_case; // = { 1, 1, 2, 3, 5 }; + + arr &aRef = get_c_array ( test_case ); + BOOST_TEST ( &*test_case.begin () == &aRef[0] ); + + const arr &caRef = get_c_array ( test_case ); + typename test_type::const_iterator iter = test_case.begin (); + BOOST_TEST ( &*iter == &caRef[0] ); + + // Confirm at() throws the std lib defined exception + try { + test_case.at( test_case.size()); + BOOST_TEST(false); + } + catch ( const std::out_of_range & ) {} + + try { + test_case.at( test_case.size() + 1); + BOOST_TEST(false); + } + catch ( const std::out_of_range & ) {} + + try { + test_case.at( test_case.size() + 100); + BOOST_TEST(false); + } + catch ( const std::out_of_range & ) {} + } +} + +int main () +{ + RunTests< bool >(); + RunTests< void * >(); + RunTests< long double >(); + RunTests< std::string >(); + + return boost::report_errors(); +} + diff --git a/src/boost/libs/array/test/array7.cpp b/src/boost/libs/array/test/array7.cpp new file mode 100644 index 000000000..567b2e61a --- /dev/null +++ b/src/boost/libs/array/test/array7.cpp @@ -0,0 +1,66 @@ +/* tests using std::get on boost:array + * (C) Copyright Marshall Clow 2012 + * 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 <string> +#include <iostream> +#include <boost/array.hpp> +#include <algorithm> +#ifndef BOOST_NO_CXX11_HDR_ARRAY +#include <array> +#endif + +#include <boost/core/lightweight_test_trait.hpp> + +namespace { + + #ifndef BOOST_NO_CXX11_HDR_ARRAY + template< class T > + void RunStdTests() + { + typedef boost::array< T, 5 > test_type; + test_type test_case; // = { 1, 1, 2, 3, 5 }; + + T &aRef = std::get<0> ( test_case ); + BOOST_TEST ( &*test_case.begin () == &aRef ); + + const T &caRef = std::get<0> ( test_case ); + BOOST_TEST ( &*test_case.cbegin () == &caRef ); + } + #endif + + template< class T > + void RunBoostTests() + { + typedef boost::array< T, 5 > test_type; + test_type test_case; // = { 1, 1, 2, 3, 5 }; + + T &aRef = boost::get<0> ( test_case ); + BOOST_TEST ( &*test_case.begin () == &aRef ); + + const T &caRef = boost::get<0> ( test_case ); + BOOST_TEST ( &*test_case.cbegin () == &caRef ); + } + +} + +int main() +{ + RunBoostTests< bool >(); + RunBoostTests< void * >(); + RunBoostTests< long double >(); + RunBoostTests< std::string >(); + +#ifndef BOOST_NO_CXX11_HDR_ARRAY + RunStdTests< bool >(); + RunStdTests< void * >(); + RunStdTests< long double >(); + RunStdTests< std::string >(); +#endif + + return boost::report_errors(); +} + diff --git a/src/boost/libs/array/test/array_constexpr.cpp b/src/boost/libs/array/test/array_constexpr.cpp new file mode 100644 index 000000000..a3110057a --- /dev/null +++ b/src/boost/libs/array/test/array_constexpr.cpp @@ -0,0 +1,39 @@ +/* tests using constexpr on boost:array + * (C) Copyright Marshall Clow 2012 + * 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 <string> +#include <iostream> +#include <boost/array.hpp> +#include <algorithm> +#ifndef BOOST_NO_CXX11_HDR_ARRAY +#include <array> +#endif + +#ifndef BOOST_NO_CXX11_CONSTEXPR +constexpr boost::array<int, 10> arr {{ 0,1,2,3,4,5,6,7,8,9 }}; +constexpr std::array<int, 10> arr_std {{ 0,1,2,3,4,5,6,7,8,9 }}; + +template <typename T> +void sink ( T t ) {} + +template <typename T, size_t N> +void sink ( boost::array<T,N> &arr ) {} + +int main() +{ +// constexpr int two = arr_std.at (2); + constexpr int three = arr.at (3); + int whatever [ arr.at(4) ]; + (void)three; + (void) whatever; +} + +#else // no constexpr means no constexpr tests! +int main() +{ +} +#endif diff --git a/src/boost/libs/array/test/array_getfail1.cpp b/src/boost/libs/array/test/array_getfail1.cpp new file mode 100644 index 000000000..d89b1ff1a --- /dev/null +++ b/src/boost/libs/array/test/array_getfail1.cpp @@ -0,0 +1,50 @@ +/* tests using std::get on boost:array + * (C) Copyright Marshall Clow 2012 + * 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 <boost/array.hpp> +#include <boost/static_assert.hpp> + + +#include <string> +#include <iostream> +#include <algorithm> +#ifndef BOOST_NO_CXX11_HDR_ARRAY +#include <array> +#endif + +#include <boost/core/lightweight_test_trait.hpp> + +namespace { + + #ifndef BOOST_NO_CXX11_HDR_ARRAY + template< class T > + void RunStdTests() + { + typedef boost::array< T, 5 > test_type; + typedef T arr[5]; + test_type test_case; // = { 1, 1, 2, 3, 5 }; + + T &aRef = std::get<5> ( test_case ); // should fail to compile + BOOST_TEST ( &*test_case.begin () == &aRef ); + } + #endif + +} + +int main() +{ +#ifndef BOOST_NO_CXX11_HDR_ARRAY + RunStdTests< bool >(); + RunStdTests< void * >(); + RunStdTests< long double >(); + RunStdTests< std::string >(); +#else + BOOST_STATIC_ASSERT ( false ); // fail on C++03 systems. +#endif + + return boost::report_errors(); +} diff --git a/src/boost/libs/array/test/array_getfail2.cpp b/src/boost/libs/array/test/array_getfail2.cpp new file mode 100644 index 000000000..d8073dba9 --- /dev/null +++ b/src/boost/libs/array/test/array_getfail2.cpp @@ -0,0 +1,65 @@ +/* tests using std::get on boost:array + * (C) Copyright Marshall Clow 2012 + * 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 <string> +#include <iostream> +#include <boost/array.hpp> +#include <algorithm> +#ifndef BOOST_NO_CXX11_HDR_ARRAY +#include <array> +#endif + +#include <boost/core/lightweight_test_trait.hpp> + +namespace { + + #ifndef BOOST_NO_CXX11_HDR_ARRAY + template< class T > + void RunStdTests() + { + typedef boost::array< T, 5 > test_type; + typedef T arr[5]; + test_type test_case; // = { 1, 1, 2, 3, 5 }; + + T &aRef = std::get<0> ( test_case ); + BOOST_TEST ( &*test_case.begin () == &aRef ); + + const T &caRef = std::get<0> ( test_case ); + BOOST_TEST ( &*test_case.cbegin () == &caRef ); + } + #endif + + template< class T > + void RunBoostTests() + { + typedef boost::array< T, 5 > test_type; + typedef T arr[5]; + test_type test_case; // = { 1, 1, 2, 3, 5 }; + + T &aRef = boost::get<5> ( test_case ); + BOOST_TEST ( &*test_case.begin () == &aRef ); + } + +} + +int main() +{ + RunBoostTests< bool >(); + RunBoostTests< void * >(); + RunBoostTests< long double >(); + RunBoostTests< std::string >(); + +#ifndef BOOST_NO_CXX11_HDR_ARRAY + RunStdTests< bool >(); + RunStdTests< void * >(); + RunStdTests< long double >(); + RunStdTests< std::string >(); +#endif + + return boost::report_errors(); +} + diff --git a/src/boost/libs/array/test/array_hash.cpp b/src/boost/libs/array/test/array_hash.cpp new file mode 100644 index 000000000..f22fc5109 --- /dev/null +++ b/src/boost/libs/array/test/array_hash.cpp @@ -0,0 +1,44 @@ +/* tests for using boost::hash with boost::array + * (C) Copyright Marshall Clow 2012 + * 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 <string> +#include <iostream> +#include <boost/array.hpp> +#include <algorithm> +#include <boost/functional/hash.hpp> + +#include <boost/core/lightweight_test_trait.hpp> + +namespace { + + template< class T > + void RunTests() + { + // std::size_t hash0 = boost::hash<boost::array<T,0> > () ( boost::array<T, 0> ()); + // std::size_t hash1 = boost::hash<boost::array<T,1> > () ( boost::array<T, 1> ()); + + typedef boost::array< T, 5 > barr; + typedef T arr[5]; + barr test_barr = {{ 1, 1, 2, 3, 5 }}; + arr test_arr = { 1, 1, 2, 3, 5 }; + + std::size_t bhash = boost::hash<barr> () ( test_barr ); + std::size_t ahash = boost::hash<arr> () ( test_arr ); + BOOST_TEST ( ahash == bhash ); + } + +} + +int main() +{ + RunTests< int >(); + RunTests< long >(); + RunTests< long double >(); + + return boost::report_errors(); +} + diff --git a/src/boost/libs/array/test/print.hpp b/src/boost/libs/array/test/print.hpp new file mode 100644 index 000000000..6d68e8e1b --- /dev/null +++ b/src/boost/libs/array/test/print.hpp @@ -0,0 +1,27 @@ +/* The following code example is taken from the book + * "The C++ Standard Library - A Tutorial and Reference" + * by Nicolai M. Josuttis, Addison-Wesley, 1999 + * + * (C) Copyright Nicolai M. Josuttis 1999. + * 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 <iostream> + +/* print_elements() + * - prints optional C-string optcstr followed by + * - all elements of the collection coll + * - separated by spaces + */ +template <class T> +inline void print_elements (const T& coll, const char* optcstr="") +{ + typename T::const_iterator pos; + + std::cout << optcstr; + for (pos=coll.begin(); pos!=coll.end(); ++pos) { + std::cout << *pos << ' '; + } + std::cout << std::endl; +} diff --git a/src/boost/libs/array/test/test_cmake/CMakeLists.txt b/src/boost/libs/array/test/test_cmake/CMakeLists.txt new file mode 100644 index 000000000..d1bce85a2 --- /dev/null +++ b/src/boost/libs/array/test/test_cmake/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright 2018 Mike Dev +# 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 +# +# NOTE: This does NOT run the unit tests for Boost.Array. +# It only tests, if the CMakeLists.txt file in it's root works as expected + +cmake_minimum_required( VERSION 3.5 ) + +project( BoostBindCMakeSelfTest ) + +add_subdirectory( ../../../assert ${CMAKE_CURRENT_BINARY_DIR}/libs/assert ) +add_subdirectory( ../../../config ${CMAKE_CURRENT_BINARY_DIR}/libs/config ) +add_subdirectory( ../../../core ${CMAKE_CURRENT_BINARY_DIR}/libs/core ) +add_subdirectory( ../../../static_assert ${CMAKE_CURRENT_BINARY_DIR}/libs/static_assert ) +add_subdirectory( ../../../throw_exception ${CMAKE_CURRENT_BINARY_DIR}/libs/thorw_exception ) + +add_subdirectory( ../.. ${CMAKE_CURRENT_BINARY_DIR}/libs/boost_array ) + +add_executable( boost_array_cmake_self_test main.cpp ) +target_link_libraries( boost_array_cmake_self_test Boost::array ) + diff --git a/src/boost/libs/array/test/test_cmake/main.cpp b/src/boost/libs/array/test/test_cmake/main.cpp new file mode 100644 index 000000000..c2e0c905c --- /dev/null +++ b/src/boost/libs/array/test/test_cmake/main.cpp @@ -0,0 +1,5 @@ +#include <boost/array.hpp> + +int main() { + boost::array<int,5> a{}; +}
\ No newline at end of file |