From 1f8298fb087b4c07efce300c489d7b08f6751e7d Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 21 Mar 2006 02:26:31 +0000 Subject: [PATCH 001/154] This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'. [SVN r33417] From 276cd991f3e0e12442f12b7f249b02272f41973e Mon Sep 17 00:00:00 2001 From: Alisdair Meredith Date: Sat, 3 Jun 2006 13:04:27 +0000 Subject: [PATCH 002/154] Support for zero length arrays [SVN r34156] --- array0.cpp | 107 ++++++++++++++++++++++++++++++++++++ include/boost/array.hpp | 119 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 224 insertions(+), 2 deletions(-) create mode 100644 array0.cpp diff --git a/array0.cpp b/array0.cpp new file mode 100644 index 00000000..e6e5e8ba --- /dev/null +++ b/array0.cpp @@ -0,0 +1,107 @@ +/* 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 +#include +#include + +namespace { +unsigned int failed_tests = 0; + +void fail_test( const char * reason ) { + ++failed_tests; + std::cerr << "Test failure " << failed_tests << ": " << reason << std::endl; +} + +template< class T > +void BadValue( const T & ) +{ + fail_test( "Unexpected value" ); +} + +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.assign( T() ); + + // front/back and operator[] must compile, but calling them is undefined + // Likewise, all tests below should evaluate to false, avoiding undefined behaviour + if( !test_case.empty() ) { + BadValue( test_case.front() ); + } + + if( !const_test_case.empty() ) { + BadValue( const_test_case.back() ); + } + + if( test_case.size() > 0 ) { + BadValue( test_case[ 0 ] ); + } + + if( const_test_case.max_size() > 0 ) { + BadValue( const_test_case[ 0 ] ); + } + + // Assert requirements of TR1 6.2.2.4 + if( test_case.begin() != test_case.end() ) { + fail_test( "Not an empty range" ); + } + if( const_test_case.begin() != const_test_case.end() ) { + fail_test( "Not an empty range" ); + } + + if( test_case.begin() == const_test_case.begin() ) { + fail_test( "iterators for different containers are not distinct" ); + } + + 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( const_test_case.begin(), const_test_case.end(), BadValue< T > ); + std::for_each( const_test_case.rbegin(), const_test_case.rend(), BadValue< T > ); + + // Check swap is well formed + std::swap( test_case, test_case ); + + // Check assigment 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::range_error & ) { + } + + try { + BadValue( const_test_case.at( 0 ) ); + } catch ( const std::range_error & ) { + } +} + +} + +int main() +{ + RunTests< bool >(); + RunTests< void * >(); + RunTests< long double >(); + RunTests< std::string >(); + return failed_tests; +} + diff --git a/include/boost/array.hpp b/include/boost/array.hpp index ce9eda7b..841ed763 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -52,7 +52,7 @@ namespace boost { typedef const T& const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; - + // iterator support iterator begin() { return elems; } const_iterator begin() const { return elems; } @@ -135,6 +135,7 @@ namespace boost { // direct access to data (read-only) const T* data() const { return elems; } + T* data() { return elems; } // use array as C array (direct read/write access to data) T* c_array() { return elems; } @@ -154,13 +155,127 @@ namespace boost { // check range (may be private because it is static) static void rangecheck (size_type i) { - if (i >= size()) { + if (i >= size()) { throw std::range_error("array<>: index out of range"); } } }; + template< class T > + class array< T, 0 > { + + public: + // type definitions + typedef T value_type; + typedef T* iterator; + typedef const T* const_iterator; + typedef T& reference; + typedef const T& const_reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + // iterator support + iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); } + const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); } + iterator end() { return begin(); } + const_iterator end() const { return begin(); } + + // reverse iterator support +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; +#elif defined(_MSC_VER) && (_MSC_VER == 1300) && defined(BOOST_DINKUMWARE_STDLIB) && (BOOST_DINKUMWARE_STDLIB == 310) + // workaround for broken reverse_iterator in VC7 + typedef std::reverse_iterator > reverse_iterator; + typedef std::reverse_iterator > const_reverse_iterator; +#else + // workaround for broken reverse_iterator implementations + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; +#endif + + reverse_iterator rbegin() { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const { + return const_reverse_iterator(end()); + } + reverse_iterator rend() { return reverse_iterator(begin()); } + const_reverse_iterator rend() const { + return const_reverse_iterator(begin()); + } + + // operator[] + reference operator[](size_type i) + { + BOOST_ASSERT( "out of range" ); + failed_rangecheck(); + } + + const_reference operator[](size_type i) const + { + BOOST_ASSERT( "out of range" ); + failed_rangecheck(); + } + + // at() with range check + reference at(size_type i) { failed_rangecheck(); } + const_reference at(size_type i) const { failed_rangecheck(); } + + // front() and back() + reference front() + { + failed_rangecheck(); + } + + const_reference front() const + { + failed_rangecheck(); + } + + reference back() + { + failed_rangecheck(); + } + + const_reference back() const + { + failed_rangecheck(); + } + + // size is constant + static size_type size() { return 0; } + static bool empty() { return true; } + static size_type max_size() { return 0; } + enum { static_size = 0 }; + + void swap (array& y) { + } + + // direct access to data (read-only) + const T* data() const { return 0; } + T* data() { return 0; } + + // use array as C array (direct read/write access to data) + T* c_array() { return 0; } + + // assignment with type conversion + template + array& operator= (const array& ) { + return *this; + } + + // assign one value to all elements + void assign (const T& ) { } + + // check range (may be private because it is static) + static void failed_rangecheck () { + throw std::range_error("attempt to access element of an empty array"); + } + + }; + // comparisons template bool operator== (const array& x, const array& y) { From 4c5212f5e45db2fd28c3c190137903aeba43372c Mon Sep 17 00:00:00 2001 From: Alisdair Meredith Date: Sun, 4 Jun 2006 12:10:17 +0000 Subject: [PATCH 003/154] Remove size zero support for old compilers that do not support partial template specialization [SVN r34162] --- include/boost/array.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 841ed763..102664ed 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -162,6 +162,7 @@ namespace boost { }; +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template< class T > class array< T, 0 > { @@ -273,8 +274,8 @@ namespace boost { static void failed_rangecheck () { throw std::range_error("attempt to access element of an empty array"); } - }; +#endif // comparisons template From 69188c998fd735a0c5e59aa93657d9e4c7ec249e Mon Sep 17 00:00:00 2001 From: John Maddock Date: Fri, 9 Jun 2006 11:40:07 +0000 Subject: [PATCH 004/154] Fix compiler errors resulting from missing return values. [SVN r34259] --- include/boost/array.hpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 102664ed..7eef6aff 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -30,6 +30,7 @@ // Handles broken standard libraries better than #include +#include #include // FIXES for broken compilers @@ -212,37 +213,43 @@ namespace boost { { BOOST_ASSERT( "out of range" ); failed_rangecheck(); + return null_item(); } const_reference operator[](size_type i) const { BOOST_ASSERT( "out of range" ); failed_rangecheck(); + return null_item(); } // at() with range check - reference at(size_type i) { failed_rangecheck(); } - const_reference at(size_type i) const { failed_rangecheck(); } + reference at(size_type i) { failed_rangecheck(); return null_item(); } + const_reference at(size_type i) const { failed_rangecheck(); return null_item(); } // front() and back() reference front() { failed_rangecheck(); + return null_item(); } const_reference front() const { failed_rangecheck(); + return null_item(); } reference back() { failed_rangecheck(); + return null_item(); } const_reference back() const { failed_rangecheck(); + return null_item(); } // size is constant @@ -272,8 +279,19 @@ namespace boost { // check range (may be private because it is static) static void failed_rangecheck () { - throw std::range_error("attempt to access element of an empty array"); + std::range_error e("attempt to access element of an empty array"); + boost::throw_exception(e); } + static reference null_item() + { + // + // This function must exist to allow our various interfaces to + // actually compile, however it will never be called, because + // an exception will always be thrown before we get here. + // + static T placeholder; + return placeholder; + } }; #endif From 3044ab376ce8559b3920de47f97ae023b342dcb9 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sat, 24 Jun 2006 11:31:19 +0000 Subject: [PATCH 005/154] Simplified code. [SVN r34384] --- include/boost/array.hpp | 43 +++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 7eef6aff..21e5f1bd 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -211,45 +211,37 @@ namespace boost { // operator[] reference operator[](size_type i) { - BOOST_ASSERT( "out of range" ); - failed_rangecheck(); - return null_item(); + return failed_rangecheck(); } const_reference operator[](size_type i) const { - BOOST_ASSERT( "out of range" ); - failed_rangecheck(); - return null_item(); + return failed_rangecheck(); } // at() with range check - reference at(size_type i) { failed_rangecheck(); return null_item(); } - const_reference at(size_type i) const { failed_rangecheck(); return null_item(); } + reference at(size_type i) { return failed_rangecheck(); } + const_reference at(size_type i) const { return failed_rangecheck(); } // front() and back() reference front() { - failed_rangecheck(); - return null_item(); + return failed_rangecheck(); } const_reference front() const { - failed_rangecheck(); - return null_item(); + return failed_rangecheck(); } reference back() { - failed_rangecheck(); - return null_item(); + return failed_rangecheck(); } const_reference back() const { - failed_rangecheck(); - return null_item(); + return failed_rangecheck(); } // size is constant @@ -278,20 +270,17 @@ namespace boost { void assign (const T& ) { } // check range (may be private because it is static) - static void failed_rangecheck () { + static reference failed_rangecheck () { std::range_error e("attempt to access element of an empty array"); boost::throw_exception(e); + // + // We need to return something here to keep + // some compilers happy: however we will never + // actually get here.... + // + static T placeholder; + return placeholder; } - static reference null_item() - { - // - // This function must exist to allow our various interfaces to - // actually compile, however it will never be called, because - // an exception will always be thrown before we get here. - // - static T placeholder; - return placeholder; - } }; #endif From b6522b3f601a38412d5be65c82594c7959236658 Mon Sep 17 00:00:00 2001 From: Gennaro Prota Date: Tue, 8 Aug 2006 18:53:30 +0000 Subject: [PATCH 006/154] (merge from head) http://www.josuttis.com/ hasn't the latest version any more [SVN r34856] --- include/boost/array.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 21e5f1bd..b41c6561 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -2,13 +2,13 @@ * an STL container (as wrapper) for arrays of constant size. * * See - * http://www.josuttis.com/cppcode - * for details and the latest version. - * See - * http://www.boost.org/libs/array for Documentation. + * http://www.boost.org/libs/array/ * for documentation. * + * The original author site is at: http://www.josuttis.com/ + * * (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) From e85feee293aa081e30d1cd0b3eb580d24779fb66 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Tue, 7 Nov 2006 19:27:00 +0000 Subject: [PATCH 007/154] Merged copyright and license addition [SVN r35907] --- index.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 588f27e2..a9e3c343 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,10 @@ Automatic redirection failed, please go to -../../doc/html/array.html +../../doc/html/array.html  
+

© Copyright Beman Dawes, 2001

+

Distributed under the Boost Software License, Version 1.0. (See accompanying +file LICENSE_1_0.txt or copy +at www.boost.org/LICENSE_1_0.txt)

- + \ No newline at end of file From 5a23b06a83bbc7aa61ab5e0b21587bd39f5d5b68 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Fri, 1 Dec 2006 11:34:43 +0000 Subject: [PATCH 008/154] Merged L & C issue fixes from trunk to branch. [SVN r36225] --- doc/array.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/array.xml b/doc/array.xml index e09c0c01..fca63a65 100644 --- a/doc/array.xml +++ b/doc/array.xml @@ -17,11 +17,11 @@ - Permission to copy, use, modify, sell and distribute this - software is granted provided this copyright notice appears in - all copies. This software is provided "as is" without express or - implied warranty, and with no claim as to its suitability for - any purpose. + 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) + STL compliant container wrapper for arrays of constant size From 96d4c5f73786ce575f07f278e236b5960816f369 Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 24 Jul 2007 19:28:14 +0000 Subject: [PATCH 009/154] This commit was manufactured by cvs2svn to create tag 'Version_1_34_1'. [SVN r38286] From 0a4d7e81efdf55af47dc77c0157bdfa32137e3be Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 5 Oct 2007 14:25:06 +0000 Subject: [PATCH 010/154] Starting point for releases [SVN r39706] From 2e88dc228d17a9c04ef0dae0bb5dcf236d0f754c Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sun, 25 Nov 2007 18:07:19 +0000 Subject: [PATCH 011/154] Full merge from trunk at revision 41356 of entire boost-root tree. [SVN r41369] --- include/boost/array.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index b41c6561..52218aac 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -157,7 +157,7 @@ namespace boost { // check range (may be private because it is static) static void rangecheck (size_type i) { if (i >= size()) { - throw std::range_error("array<>: index out of range"); + throw std::out_of_range("array<>: index out of range"); } } @@ -271,7 +271,7 @@ namespace boost { // check range (may be private because it is static) static reference failed_rangecheck () { - std::range_error e("attempt to access element of an empty array"); + std::out_of_range e("attempt to access element of an empty array"); boost::throw_exception(e); // // We need to return something here to keep From 4dd2cf1b648aee13e0a861c86450b4ce00a14ea0 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Sun, 25 Nov 2007 18:38:02 +0000 Subject: [PATCH 012/154] Full merge from trunk at revision 41356 of entire boost-root tree. [SVN r41370] --- array0.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/array0.cpp b/array0.cpp index e6e5e8ba..065256b0 100644 --- a/array0.cpp +++ b/array0.cpp @@ -85,12 +85,12 @@ void RunTests() // Confirm at() throws the std lib defined exception try { BadValue( test_case.at( 0 ) ); - } catch ( const std::range_error & ) { + } catch ( const std::out_of_range & ) { } try { BadValue( const_test_case.at( 0 ) ); - } catch ( const std::range_error & ) { + } catch ( const std::out_of_range & ) { } } From e7122b3f207d6cb697ba61ffb37ce033378260cb Mon Sep 17 00:00:00 2001 From: Boris Gubenko Date: Sun, 4 Jan 2009 05:17:02 +0000 Subject: [PATCH 013/154] merge tests and Jamfiles for 7 libraries [SVN r50456] --- test/Jamfile.v2 | 14 ++++++++++++++ array0.cpp => test/array0.cpp | 0 array1.cpp => test/array1.cpp | 0 array2.cpp => test/array2.cpp | 0 array3.cpp => test/array3.cpp | 0 array4.cpp => test/array4.cpp | 0 array5.cpp => test/array5.cpp | 0 print.hpp => test/print.hpp | 0 8 files changed, 14 insertions(+) create mode 100644 test/Jamfile.v2 rename array0.cpp => test/array0.cpp (100%) rename array1.cpp => test/array1.cpp (100%) rename array2.cpp => test/array2.cpp (100%) rename array3.cpp => test/array3.cpp (100%) rename array4.cpp => test/array4.cpp (100%) rename array5.cpp => test/array5.cpp (100%) rename print.hpp => test/print.hpp (100%) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 new file mode 100644 index 00000000..1379a5b3 --- /dev/null +++ b/test/Jamfile.v2 @@ -0,0 +1,14 @@ +#~ 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) + +import testing ; + +test-suite array : + [ run array0.cpp ] + [ run array1.cpp ] + [ run array2.cpp ] + [ run array3.cpp ] + [ run array4.cpp ] + [ run array5.cpp ] + ; diff --git a/array0.cpp b/test/array0.cpp similarity index 100% rename from array0.cpp rename to test/array0.cpp diff --git a/array1.cpp b/test/array1.cpp similarity index 100% rename from array1.cpp rename to test/array1.cpp diff --git a/array2.cpp b/test/array2.cpp similarity index 100% rename from array2.cpp rename to test/array2.cpp diff --git a/array3.cpp b/test/array3.cpp similarity index 100% rename from array3.cpp rename to test/array3.cpp diff --git a/array4.cpp b/test/array4.cpp similarity index 100% rename from array4.cpp rename to test/array4.cpp diff --git a/array5.cpp b/test/array5.cpp similarity index 100% rename from array5.cpp rename to test/array5.cpp diff --git a/print.hpp b/test/print.hpp similarity index 100% rename from print.hpp rename to test/print.hpp From 3d20bb1310193af12e842bca41a5e5465e8f172a Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 24 Jan 2009 18:57:20 +0000 Subject: [PATCH 014/154] merge of cmake build files from trunk per beman [SVN r50756] --- CMakeLists.txt | 21 +++++++++++++++++++++ module.cmake | 1 + test/CMakeLists.txt | 8 ++++++++ 3 files changed, 30 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 module.cmake create mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..39a27884 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +#---------------------------------------------------------------------------- +# This file was automatically generated from the original CMakeLists.txt file +# Add a variable to hold the headers for the library +set (lib_headers + array.hpp +) + +# Add a library target to the build system +boost_library_project( + array + # SRCDIRS + TESTDIRS test + HEADERS ${lib_headers} + # DOCDIRS + DESCRIPTION "STL compliant container wrapper for arrays of constant size." + MODULARIZED + AUTHORS "Nicolai Josuttis" + # MAINTAINERS +) + + diff --git a/module.cmake b/module.cmake new file mode 100644 index 00000000..ccd28139 --- /dev/null +++ b/module.cmake @@ -0,0 +1 @@ +boost_module(array DEPENDS utility) \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..2301077e --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,8 @@ +boost_additional_test_dependencies(array BOOST_DEPENDS test) + +boost_test_run(array0 array0.cpp) +boost_test_run(array1 array1.cpp) +boost_test_run(array2 array2.cpp) +boost_test_run(array3 array3.cpp) +boost_test_run(array4 array4.cpp) +boost_test_run(array5 array5.cpp) From 86b069ad0e6dd4ebcc3f16037851201a335039f6 Mon Sep 17 00:00:00 2001 From: Steven Watanabe Date: Sat, 23 May 2009 06:00:42 +0000 Subject: [PATCH 015/154] Merge [53104] and [53105] from the trunk [SVN r53198] --- include/boost/array.hpp | 14 ++++++++------ test/array3.cpp | 2 +- test/array5.cpp | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 52218aac..8ef73c42 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -27,6 +27,7 @@ #include #include #include +#include // Handles broken standard libraries better than #include @@ -131,7 +132,8 @@ namespace boost { // swap (note: linear complexity) void swap (array& y) { - std::swap_ranges(begin(),end(),y.begin()); + for (size_type i = 0; i < N; ++i) + boost::swap(elems[i],y.elems[i]); } // direct access to data (read-only) @@ -209,19 +211,19 @@ namespace boost { } // operator[] - reference operator[](size_type i) + reference operator[](size_type /*i*/) { return failed_rangecheck(); } - const_reference operator[](size_type i) const + const_reference operator[](size_type /*i*/) const { return failed_rangecheck(); } // at() with range check - reference at(size_type i) { return failed_rangecheck(); } - const_reference at(size_type i) const { return failed_rangecheck(); } + reference at(size_type /*i*/) { return failed_rangecheck(); } + const_reference at(size_type /*i*/) const { return failed_rangecheck(); } // front() and back() reference front() @@ -250,7 +252,7 @@ namespace boost { static size_type max_size() { return 0; } enum { static_size = 0 }; - void swap (array& y) { + void swap (array& /*y*/) { } // direct access to data (read-only) diff --git a/test/array3.cpp b/test/array3.cpp index a4eac5d8..b815fe75 100644 --- a/test/array3.cpp +++ b/test/array3.cpp @@ -21,7 +21,7 @@ int main() // copy and change order boost::array seasons_orig = seasons; - for (unsigned i=seasons.size()-1; i>0; --i) { + for (std::size_t i=seasons.size()-1; i>0; --i) { std::swap(seasons.at(i),seasons.at((i+1)%seasons.size())); } diff --git a/test/array5.cpp b/test/array5.cpp index d6c472a8..23156b9c 100644 --- a/test/array5.cpp +++ b/test/array5.cpp @@ -27,7 +27,7 @@ int main() typedef boost::array Array; // create and initialize an array - const Array a = { { 42.42 } }; + const Array a = { { 42.42f } }; // use some common STL container operations std::cout << "static_size: " << a.size() << std::endl; From 5661b8cd6322a078874af4cf7008f5437fb5cba3 Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Wed, 22 Jul 2009 21:51:01 +0000 Subject: [PATCH 016/154] Add basic copyright/license to keep cmake out of the inspection report [SVN r55095] --- CMakeLists.txt | 6 ++++++ test/CMakeLists.txt | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39a27884..ecdd5036 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,9 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# #---------------------------------------------------------------------------- # This file was automatically generated from the original CMakeLists.txt file # Add a variable to hold the headers for the library diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2301077e..379e7b19 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,9 @@ +# +# Copyright Troy D. Straszheim +# +# Distributed under the Boost Software License, Version 1.0. +# See http://www.boost.org/LICENSE_1_0.txt +# boost_additional_test_dependencies(array BOOST_DEPENDS test) boost_test_run(array0 array0.cpp) From 99631823f626e28ca7cc68aebefde497e88ab2fa Mon Sep 17 00:00:00 2001 From: "Troy D. Straszheim" Date: Sat, 17 Oct 2009 01:10:45 +0000 Subject: [PATCH 017/154] rm cmake from the release branch before it goes out broken. Policy dictates that you never commit to release, you commit to trunk and merge to release. [SVN r56941] --- CMakeLists.txt | 27 --------------------------- module.cmake | 1 - test/CMakeLists.txt | 14 -------------- 3 files changed, 42 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 module.cmake delete mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index ecdd5036..00000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -#---------------------------------------------------------------------------- -# This file was automatically generated from the original CMakeLists.txt file -# Add a variable to hold the headers for the library -set (lib_headers - array.hpp -) - -# Add a library target to the build system -boost_library_project( - array - # SRCDIRS - TESTDIRS test - HEADERS ${lib_headers} - # DOCDIRS - DESCRIPTION "STL compliant container wrapper for arrays of constant size." - MODULARIZED - AUTHORS "Nicolai Josuttis" - # MAINTAINERS -) - - diff --git a/module.cmake b/module.cmake deleted file mode 100644 index ccd28139..00000000 --- a/module.cmake +++ /dev/null @@ -1 +0,0 @@ -boost_module(array DEPENDS utility) \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 379e7b19..00000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# -# Copyright Troy D. Straszheim -# -# Distributed under the Boost Software License, Version 1.0. -# See http://www.boost.org/LICENSE_1_0.txt -# -boost_additional_test_dependencies(array BOOST_DEPENDS test) - -boost_test_run(array0 array0.cpp) -boost_test_run(array1 array1.cpp) -boost_test_run(array2 array2.cpp) -boost_test_run(array3 array3.cpp) -boost_test_run(array4 array4.cpp) -boost_test_run(array5 array5.cpp) From 88868ba0df022401394ae20b491a7f634276f38c Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 12 Jan 2010 05:55:52 +0000 Subject: [PATCH 018/154] Merged array changes from trunk to release [SVN r58921] --- include/boost/array.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 8ef73c42..d58b93ad 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -24,6 +24,13 @@ #ifndef BOOST_ARRAY_HPP #define BOOST_ARRAY_HPP +#include + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(push) +# pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe +#endif + #include #include #include @@ -320,4 +327,9 @@ namespace boost { } /* namespace boost */ + +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(pop) +#endif + #endif /*BOOST_ARRAY_HPP*/ From 0c8902e8c2a4c1bb5aadbfee941e739703166184 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 25 Mar 2010 15:32:12 +0000 Subject: [PATCH 019/154] Merged array changes from trunk to release; Fixes #3893 and #3168 [SVN r60824] --- include/boost/array.hpp | 29 +++++++++++++++++++++++++---- test/array0.cpp | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index d58b93ad..64964699 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -13,6 +13,10 @@ * accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * + * 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group. + * See or Trac issue #3168 + * Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow) + * 10 Mar 2010 - added workaround for SUNCC and !STLPort [trac #3893] (Marshall Clow) * 29 Jan 2004 - c_array() added, BOOST_NO_PRIVATE_IN_AGGREGATE removed (Nico Josuttis) * 23 Aug 2002 - fix for Non-MSVC compilers combined with MSVC libraries. * 05 Aug 2001 - minor update (Nico Josuttis) @@ -29,6 +33,8 @@ #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) # pragma warning(push) # pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe +# pragma warning(disable:4510) // boost::array' : default constructor could not be generated +# pragma warning(disable:4610) // warning C4610: class 'boost::array' can never be instantiated - user defined constructor required #endif #include @@ -78,6 +84,11 @@ namespace boost { reference, iterator, reference> > reverse_iterator; typedef std::reverse_iterator > const_reverse_iterator; +#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; #else // workaround for broken reverse_iterator implementations typedef std::reverse_iterator reverse_iterator; @@ -158,7 +169,8 @@ namespace boost { } // assign one value to all elements - void assign (const T& value) + void assign (const T& value) { fill ( value ); } // A synonym for fill + void fill (const T& value) { std::fill_n(begin(),size(),value); } @@ -166,7 +178,8 @@ namespace boost { // check range (may be private because it is static) static void rangecheck (size_type i) { if (i >= size()) { - throw std::out_of_range("array<>: index out of range"); + std::out_of_range e("array<>: index out of range"); + boost::throw_exception(e); } } @@ -202,6 +215,11 @@ namespace boost { reference, iterator, reference> > reverse_iterator; typedef std::reverse_iterator > const_reverse_iterator; +#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; #else // workaround for broken reverse_iterator implementations typedef std::reverse_iterator reverse_iterator; @@ -276,12 +294,14 @@ namespace boost { } // assign one value to all elements - void assign (const T& ) { } - + void assign (const T& value) { fill ( value ); } + void fill (const T& ) {} + // check range (may be private because it is static) static reference failed_rangecheck () { std::out_of_range e("attempt to access element of an empty array"); boost::throw_exception(e); +#if defined(BOOST_NO_EXCEPTIONS) || !defined(BOOST_MSVC) // // We need to return something here to keep // some compilers happy: however we will never @@ -289,6 +309,7 @@ namespace boost { // static T placeholder; return placeholder; +#endif } }; #endif diff --git a/test/array0.cpp b/test/array0.cpp index 065256b0..92135f1a 100644 --- a/test/array0.cpp +++ b/test/array0.cpp @@ -32,7 +32,7 @@ void RunTests() test_type test_case = {}; const boost::array< T, 0 > const_test_case = test_type(); - test_case.assign( T() ); + 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 From a603bffc48f178021926259f146bc8c216b621a2 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 28 Jun 2010 17:59:21 +0000 Subject: [PATCH 020/154] Merged Array changes to release [SVN r63410] --- include/boost/array.hpp | 42 ++++++++++++++++++++++++++++++++++++----- test/array2.cpp | 5 +++++ 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 64964699..7df27714 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -14,8 +14,8 @@ * http://www.boost.org/LICENSE_1_0.txt) * * 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group. - * See or Trac issue #3168 - * Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow) + * See or Trac issue #3168 + * Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow) * 10 Mar 2010 - added workaround for SUNCC and !STLPort [trac #3893] (Marshall Clow) * 29 Jan 2004 - c_array() added, BOOST_NO_PRIVATE_IN_AGGREGATE removed (Nico Josuttis) * 23 Aug 2002 - fix for Non-MSVC compilers combined with MSVC libraries. @@ -169,7 +169,7 @@ namespace boost { } // assign one value to all elements - void assign (const T& value) { fill ( value ); } // A synonym for fill + void assign (const T& value) { fill ( value ); } // A synonym for fill void fill (const T& value) { std::fill_n(begin(),size(),value); @@ -295,8 +295,8 @@ namespace boost { // assign one value to all elements void assign (const T& value) { fill ( value ); } - void fill (const T& ) {} - + void fill (const T& ) {} + // check range (may be private because it is static) static reference failed_rangecheck () { std::out_of_range e("attempt to access element of an empty array"); @@ -346,6 +346,38 @@ namespace boost { x.swap(y); } + // Specific for boost::array: simply returns its elems data member. + template + T(&get_c_array(boost::array& arg))[N] + { + return arg.elems; + } + + // Const version. + template + const T(&get_c_array(const boost::array& arg))[N] + { + return arg.elems; + } + +#if 0 + // Overload for std::array, assuming that std::array will have + // explicit conversion functions as discussed at the WG21 meeting + // in Summit, March 2009. + template + T(&get_c_array(std::array& arg))[N] + { + return static_cast(arg); + } + + // Const version. + template + const T(&get_c_array(const std::array& arg))[N] + { + return static_cast(arg); + } +#endif + } /* namespace boost */ diff --git a/test/array2.cpp b/test/array2.cpp index abbc745b..1c8ccf83 100644 --- a/test/array2.cpp +++ b/test/array2.cpp @@ -5,6 +5,11 @@ * 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 #include #include From 9644ee6662f3ad9cc9f99dd0750e13bd4c5d075b Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 28 Dec 2010 18:28:22 +0000 Subject: [PATCH 021/154] Merged array changes to release; fixes #4757 [SVN r67477] --- include/boost/array.hpp | 32 +++++++++++++++++++++++++-- test/Jamfile.v2 | 1 + test/array6.cpp | 48 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 test/array6.cpp diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 7df27714..a5bee241 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -346,7 +346,34 @@ namespace boost { x.swap(y); } - // Specific for boost::array: simply returns its elems data member. +#if defined(__SUNPRO_CC) +// Trac ticket #4757; the Sun Solaris compiler can't handle +// syntax like 'T(&get_c_array(boost::array& arg))[N]' +// +// We can't just use this for all compilers, because the +// borland compilers can't handle this form. + namespace detail { + template struct c_array + { + typedef T type[N]; + }; + } + + // Specific for boost::array: simply returns its elems data member. + template + typename detail::c_array::type& get_c_array(boost::array& arg) + { + return arg.elems; + } + + // Specific for boost::array: simply returns its elems data member. + template + typename const detail::c_array::type& get_c_array(const boost::array& arg) + { + return arg.elems; + } +#else +// Specific for boost::array: simply returns its elems data member. template T(&get_c_array(boost::array& arg))[N] { @@ -359,7 +386,8 @@ namespace boost { { return arg.elems; } - +#endif + #if 0 // Overload for std::array, assuming that std::array will have // explicit conversion functions as discussed at the WG21 meeting diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1379a5b3..2deb3d59 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -11,4 +11,5 @@ test-suite array : [ run array3.cpp ] [ run array4.cpp ] [ run array5.cpp ] + [ run array6.cpp ] ; diff --git a/test/array6.cpp b/test/array6.cpp new file mode 100644 index 00000000..388b39f4 --- /dev/null +++ b/test/array6.cpp @@ -0,0 +1,48 @@ +/* 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 +#include +#include +#include + +namespace { +unsigned int failed_tests = 0; + +void fail_test( const char * reason ) { + ++failed_tests; + std::cerr << "Test failure " << failed_tests << ": " << reason << std::endl; +} + +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 ); + if ( &*test_case.begin () != &aRef[0] ) + fail_test ( "Array6: Same thing not equal?(1)" ); + + const arr &caRef = get_c_array ( test_case ); + typename test_type::const_iterator iter = test_case.begin (); + if ( &*iter != &caRef[0] ) + fail_test ( "Array6: Same thing not equal?(2)" ); +} + +} + +int main() +{ + RunTests< bool >(); + RunTests< void * >(); + RunTests< long double >(); + RunTests< std::string >(); + return failed_tests; +} + From 26edbea113307731baedf15d7c0a82cf5bf6d15d Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 13 Jan 2011 15:49:03 +0000 Subject: [PATCH 022/154] Merging changes to release; fixes #4761 [SVN r68100] --- include/boost/array.hpp | 53 ++++++++++++++++++++++++++++------------- test/array0.cpp | 8 +++++++ test/array3.cpp | 7 ++++++ 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index a5bee241..85b63a28 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -13,6 +13,7 @@ * accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * + * 28 Dec 2010 - (mtc) Added cbegin and cend (and crbegin and crend) for C++Ox compatibility. * 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group. * See or Trac issue #3168 * Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow) @@ -69,10 +70,13 @@ namespace boost { typedef std::ptrdiff_t difference_type; // iterator support - iterator begin() { return elems; } - const_iterator begin() const { return elems; } - iterator end() { return elems+N; } - const_iterator end() const { return elems+N; } + iterator begin() { return elems; } + const_iterator begin() const { return elems; } + const_iterator cbegin() const { return elems; } + + iterator end() { return elems+N; } + const_iterator end() const { return elems+N; } + const_iterator cend() const { return elems+N; } // reverse iterator support #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) @@ -99,10 +103,17 @@ namespace boost { const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + const_reverse_iterator crbegin() const { + return const_reverse_iterator(end()); + } + reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + const_reverse_iterator crend() const { + return const_reverse_iterator(begin()); + } // operator[] reference operator[](size_type i) @@ -200,10 +211,13 @@ namespace boost { typedef std::ptrdiff_t difference_type; // iterator support - iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); } - const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); } - iterator end() { return begin(); } - const_iterator end() const { return begin(); } + iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); } + const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); } + const_iterator cbegin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); } + + iterator end() { return begin(); } + const_iterator end() const { return begin(); } + const_iterator cend() const { return cbegin(); } // reverse iterator support #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) && !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) @@ -230,10 +244,17 @@ namespace boost { const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } + const_reverse_iterator crbegin() const { + return const_reverse_iterator(end()); + } + reverse_iterator rend() { return reverse_iterator(begin()); } const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } + const_reverse_iterator crend() const { + return const_reverse_iterator(begin()); + } // operator[] reference operator[](size_type /*i*/) @@ -347,17 +368,17 @@ namespace boost { } #if defined(__SUNPRO_CC) -// Trac ticket #4757; the Sun Solaris compiler can't handle -// syntax like 'T(&get_c_array(boost::array& arg))[N]' -// -// We can't just use this for all compilers, because the -// borland compilers can't handle this form. - namespace detail { +// Trac ticket #4757; the Sun Solaris compiler can't handle +// syntax like 'T(&get_c_array(boost::array& arg))[N]' +// +// We can't just use this for all compilers, because the +// borland compilers can't handle this form. + namespace detail { template struct c_array { typedef T type[N]; }; - } + } // Specific for boost::array: simply returns its elems data member. template @@ -387,7 +408,7 @@ namespace boost { return arg.elems; } #endif - + #if 0 // Overload for std::array, assuming that std::array will have // explicit conversion functions as discussed at the WG21 meeting diff --git a/test/array0.cpp b/test/array0.cpp index 92135f1a..d75db760 100644 --- a/test/array0.cpp +++ b/test/array0.cpp @@ -56,9 +56,15 @@ void RunTests() if( test_case.begin() != test_case.end() ) { fail_test( "Not an empty range" ); } + if( test_case.cbegin() != test_case.cend() ) { + fail_test( "Not an empty range" ); + } if( const_test_case.begin() != const_test_case.end() ) { fail_test( "Not an empty range" ); } + if( const_test_case.cbegin() != const_test_case.cend() ) { + fail_test( "Not an empty range" ); + } if( test_case.begin() == const_test_case.begin() ) { fail_test( "iterators for different containers are not distinct" ); @@ -73,8 +79,10 @@ void RunTests() // 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 ); diff --git a/test/array3.cpp b/test/array3.cpp index b815fe75..29aacb12 100644 --- a/test/array3.cpp +++ b/test/array3.cpp @@ -39,6 +39,13 @@ int main() =seasons.rbegin(); pos::const_reverse_iterator pos + =seasons.crbegin(); pos Date: Tue, 29 Mar 2011 14:47:50 +0000 Subject: [PATCH 023/154] Merge changes in Boost.Array to release [SVN r70697] --- test/array2.cpp | 3 +-- test/array6.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/test/array2.cpp b/test/array2.cpp index 1c8ccf83..b33e0b56 100644 --- a/test/array2.cpp +++ b/test/array2.cpp @@ -15,12 +15,11 @@ #include #include "print.hpp" using namespace std; -using namespace boost; int main() { // create and initialize array - array a = { { 1, 2, 3, 4, 5 } }; + boost::array a = { { 1, 2, 3, 4, 5 } }; print_elements(a); diff --git a/test/array6.cpp b/test/array6.cpp index 388b39f4..658cec6c 100644 --- a/test/array6.cpp +++ b/test/array6.cpp @@ -26,13 +26,13 @@ void RunTests() test_type test_case; // = { 1, 1, 2, 3, 5 }; arr &aRef = get_c_array ( test_case ); - if ( &*test_case.begin () != &aRef[0] ) - fail_test ( "Array6: Same thing not equal?(1)" ); - - const arr &caRef = get_c_array ( test_case ); - typename test_type::const_iterator iter = test_case.begin (); - if ( &*iter != &caRef[0] ) - fail_test ( "Array6: Same thing not equal?(2)" ); + if ( &*test_case.begin () != &aRef[0] ) + fail_test ( "Array6: Same thing not equal?(1)" ); + + const arr &caRef = get_c_array ( test_case ); + typename test_type::const_iterator iter = test_case.begin (); + if ( &*iter != &caRef[0] ) + fail_test ( "Array6: Same thing not equal?(2)" ); } } From 5a97de6f2e3c8c7565992bac7bf45b297972a73b Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 29 Mar 2011 14:49:32 +0000 Subject: [PATCH 024/154] Merge changes in Boost.Array to release [SVN r70698] --- include/boost/array.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 85b63a28..ffb504bd 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -322,7 +322,7 @@ namespace boost { static reference failed_rangecheck () { std::out_of_range e("attempt to access element of an empty array"); boost::throw_exception(e); -#if defined(BOOST_NO_EXCEPTIONS) || !defined(BOOST_MSVC) +#if defined(BOOST_NO_EXCEPTIONS) || (!defined(BOOST_MSVC) && !defined(__PATHSCALE__)) // // We need to return something here to keep // some compilers happy: however we will never From 859fb5aa97524fa817fb5649d76ca3a333b407f3 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Wed, 23 May 2012 16:35:13 +0000 Subject: [PATCH 025/154] Merged changes for Boost.Array to release; adds support for Boost.Hash [SVN r78558] --- test/Jamfile.v2 | 1 + test/array_hash.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 test/array_hash.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 2deb3d59..a09ba687 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -12,4 +12,5 @@ test-suite array : [ run array4.cpp ] [ run array5.cpp ] [ run array6.cpp ] + [ run array_hash.cpp ] ; diff --git a/test/array_hash.cpp b/test/array_hash.cpp new file mode 100644 index 00000000..474e29cb --- /dev/null +++ b/test/array_hash.cpp @@ -0,0 +1,49 @@ +/* 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 +#include +#include +#include +#include + +namespace { +unsigned int failed_tests = 0; + +void fail_test( const char * reason ) { + ++failed_tests; + std::cerr << "Test failure " << failed_tests << ": " << reason << std::endl; +} + +template< class T > +void RunTests() +{ +// std::size_t hash0 = boost::hash > () ( boost::array ()); +// std::size_t hash1 = boost::hash > () ( boost::array ()); + + 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 () ( test_barr ); + std::size_t ahash = boost::hash () ( test_arr ); + if ( ahash != bhash ) + fail_test ( "Array_hash: Hash-mismatch on " ); +} + +} + +int main() +{ + RunTests< int >(); + RunTests< long >(); + RunTests< long double >(); + + return failed_tests; +} + From 3db6930a225b4727629c6dcab2540094f63477b9 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 24 May 2012 13:04:02 +0000 Subject: [PATCH 026/154] Added support Boost.Hash; checked in a test yesterday, but forgot to merge the actual code [SVN r78581] --- include/boost/array.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index ffb504bd..fa06fa9a 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -13,6 +13,7 @@ * accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * + * 14 Apr 2012 - (mtc) Added support for boost::hash * 28 Dec 2010 - (mtc) Added cbegin and cend (and crbegin and crend) for C++Ox compatibility. * 10 Mar 2010 - (mtc) fill method added, matching resolution of the standard library working group. * See or Trac issue #3168 @@ -46,6 +47,7 @@ // Handles broken standard libraries better than #include #include +#include #include // FIXES for broken compilers @@ -118,13 +120,13 @@ namespace boost { // operator[] reference operator[](size_type i) { - BOOST_ASSERT( i < N && "out of range" ); + BOOST_ASSERT_MSG( i < N, "out of range" ); return elems[i]; } const_reference operator[](size_type i) const { - BOOST_ASSERT( i < N && "out of range" ); + BOOST_ASSERT_MSG( i < N, "out of range" ); return elems[i]; } @@ -427,6 +429,13 @@ namespace boost { } #endif + + template + std::size_t hash_value(const array& arr) + { + return boost::hash_range(arr.begin(), arr.end()); + } + } /* namespace boost */ From ba1a2437cff225257c99a3c3139e0edf2571d567 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 14 Jun 2012 16:01:03 +0000 Subject: [PATCH 027/154] Merge doc changes to release; fixes #6988 [SVN r78948] --- doc/array.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/array.xml b/doc/array.xml index fca63a65..62bf7c2b 100644 --- a/doc/array.xml +++ b/doc/array.xml @@ -70,6 +70,11 @@ Technical Report, which will extend the C++ Standard (see http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm). + Update: std::array is (as of C++11) part of the C++ standard. + The differences between boost::array and std::array are minimal. + If you are using C++11, you should consider using std::array instead of boost::array. + + Class array fulfills most but not all of the requirements of "reversible containers" (see Section 23.1, [lib.container.requirements] of the C++ From a73b6fb5824f04eb142c4180493598bdc16fd316 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 25 Feb 2013 18:43:26 +0000 Subject: [PATCH 028/154] Merged boost::algorithm::gather and updated tests for Utility, Algorithm and Utility libraries [SVN r83154] --- test/Jamfile.v2 | 11 ++++++--- test/array0.cpp | 58 +++++++++++++-------------------------------- test/array6.cpp | 40 +++++++++++++------------------ test/array_hash.cpp | 40 +++++++++++++------------------ 4 files changed, 57 insertions(+), 92 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index a09ba687..50374743 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -4,13 +4,18 @@ import testing ; +alias unit_test_framework + : # sources + /boost//unit_test_framework + ; + test-suite array : - [ run array0.cpp ] + [ run array0.cpp unit_test_framework : : : : array0 ] [ run array1.cpp ] [ run array2.cpp ] [ run array3.cpp ] [ run array4.cpp ] [ run array5.cpp ] - [ run array6.cpp ] - [ run array_hash.cpp ] + [ run array6.cpp unit_test_framework : : : : array6 ] + [ run array_hash.cpp unit_test_framework : : : : array_hash ] ; diff --git a/test/array0.cpp b/test/array0.cpp index d75db760..c1c047e1 100644 --- a/test/array0.cpp +++ b/test/array0.cpp @@ -9,18 +9,15 @@ #include #include -namespace { -unsigned int failed_tests = 0; +#define BOOST_TEST_MAIN +#include -void fail_test( const char * reason ) { - ++failed_tests; - std::cerr << "Test failure " << failed_tests << ": " << reason << std::endl; -} +namespace { template< class T > void BadValue( const T & ) { - fail_test( "Unexpected value" ); + BOOST_CHECK ( false ); } template< class T > @@ -36,46 +33,24 @@ void RunTests() // front/back and operator[] must compile, but calling them is undefined // Likewise, all tests below should evaluate to false, avoiding undefined behaviour - if( !test_case.empty() ) { - BadValue( test_case.front() ); - } - - if( !const_test_case.empty() ) { - BadValue( const_test_case.back() ); - } - - if( test_case.size() > 0 ) { - BadValue( test_case[ 0 ] ); - } + BOOST_CHECK ( test_case.empty()); + BOOST_CHECK ( const_test_case.empty()); - if( const_test_case.max_size() > 0 ) { - BadValue( const_test_case[ 0 ] ); - } + BOOST_CHECK ( test_case.size() == 0 ); + BOOST_CHECK ( const_test_case.size() == 0 ); // Assert requirements of TR1 6.2.2.4 - if( test_case.begin() != test_case.end() ) { - fail_test( "Not an empty range" ); - } - if( test_case.cbegin() != test_case.cend() ) { - fail_test( "Not an empty range" ); - } - if( const_test_case.begin() != const_test_case.end() ) { - fail_test( "Not an empty range" ); - } - if( const_test_case.cbegin() != const_test_case.cend() ) { - fail_test( "Not an empty range" ); - } - - if( test_case.begin() == const_test_case.begin() ) { - fail_test( "iterators for different containers are not distinct" ); - } + BOOST_CHECK ( test_case.begin() == test_case.end()); + BOOST_CHECK ( test_case.cbegin() == test_case.cend()); + BOOST_CHECK ( const_test_case.begin() == const_test_case.end()); + BOOST_CHECK ( const_test_case.cbegin() == const_test_case.cend()); + BOOST_CHECK ( 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 > ); @@ -87,12 +62,12 @@ void RunTests() // Check swap is well formed std::swap( test_case, test_case ); - // Check assigment operator and overloads are well formed + // 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 ) ); + BadValue( test_case.at( 0 )); } catch ( const std::out_of_range & ) { } @@ -104,12 +79,11 @@ void RunTests() } -int main() +BOOST_AUTO_TEST_CASE( test_main ) { RunTests< bool >(); RunTests< void * >(); RunTests< long double >(); RunTests< std::string >(); - return failed_tests; } diff --git a/test/array6.cpp b/test/array6.cpp index 658cec6c..3d737fd3 100644 --- a/test/array6.cpp +++ b/test/array6.cpp @@ -10,39 +10,31 @@ #include #include -namespace { -unsigned int failed_tests = 0; - -void fail_test( const char * reason ) { - ++failed_tests; - std::cerr << "Test failure " << failed_tests << ": " << reason << std::endl; -} +#define BOOST_TEST_MAIN +#include -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 }; +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 ); - if ( &*test_case.begin () != &aRef[0] ) - fail_test ( "Array6: Same thing not equal?(1)" ); + arr &aRef = get_c_array ( test_case ); + BOOST_CHECK ( &*test_case.begin () == &aRef[0] ); - const arr &caRef = get_c_array ( test_case ); - typename test_type::const_iterator iter = test_case.begin (); - if ( &*iter != &caRef[0] ) - fail_test ( "Array6: Same thing not equal?(2)" ); -} - + const arr &caRef = get_c_array ( test_case ); + typename test_type::const_iterator iter = test_case.begin (); + BOOST_CHECK ( &*iter == &caRef[0] ); + } } -int main() +BOOST_AUTO_TEST_CASE( test_main ) { RunTests< bool >(); RunTests< void * >(); RunTests< long double >(); RunTests< std::string >(); - return failed_tests; } diff --git a/test/array_hash.cpp b/test/array_hash.cpp index 474e29cb..a83eeade 100644 --- a/test/array_hash.cpp +++ b/test/array_hash.cpp @@ -11,39 +11,33 @@ #include #include -namespace { -unsigned int failed_tests = 0; +#define BOOST_TEST_MAIN +#include -void fail_test( const char * reason ) { - ++failed_tests; - std::cerr << "Test failure " << failed_tests << ": " << reason << std::endl; -} +namespace { -template< class T > -void RunTests() -{ -// std::size_t hash0 = boost::hash > () ( boost::array ()); -// std::size_t hash1 = boost::hash > () ( boost::array ()); + template< class T > + void RunTests() + { + // std::size_t hash0 = boost::hash > () ( boost::array ()); + // std::size_t hash1 = boost::hash > () ( boost::array ()); - 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 }; + 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 () ( test_barr ); - std::size_t ahash = boost::hash () ( test_arr ); - if ( ahash != bhash ) - fail_test ( "Array_hash: Hash-mismatch on " ); -} + std::size_t bhash = boost::hash () ( test_barr ); + std::size_t ahash = boost::hash () ( test_arr ); + BOOST_CHECK ( ahash == bhash ); + } } -int main() +BOOST_AUTO_TEST_CASE( test_main ) { RunTests< int >(); RunTests< long >(); RunTests< long double >(); - - return failed_tests; } From c0b1609ddbedb98d4a0c47a692ada365b83cae41 Mon Sep 17 00:00:00 2001 From: Michel Morin Date: Wed, 13 Nov 2013 03:22:55 +0000 Subject: [PATCH 029/154] Merge r86524 (Correct broken links to C++ standard papers); fixes #9212 [SVN r86673] --- doc/array.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/array.xml b/doc/array.xml index 62bf7c2b..fb1f51f6 100644 --- a/doc/array.xml +++ b/doc/array.xml @@ -68,7 +68,7 @@ Note that this class is suggested to be part of the next Technical Report, which will extend the C++ Standard (see - http://std.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1548.htm). + http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1548.htm). Update: std::array is (as of C++11) part of the C++ standard. The differences between boost::array and std::array are minimal. From 4c27456a439e6d89336dee32938087907e74bc4f Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 27 Oct 2016 20:12:38 +0100 Subject: [PATCH 030/154] Copy doc jamfile from develop It's need to build the documentation now. --- doc/Jamfile.v2 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 doc/Jamfile.v2 diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 new file mode 100644 index 00000000..b7f51b71 --- /dev/null +++ b/doc/Jamfile.v2 @@ -0,0 +1,19 @@ +#~ Copyright Marshall Clow 2013 +#~ 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) + +using boostbook ; + +boostbook standalone + : array.xml + : boost.root=../../../.. ; + +############################################################################### +alias boostdoc + : array.xml + : + : + : ; +explicit boostdoc ; +alias boostrelease ; +explicit boostrelease ; From 37c18b30948e622be52509cdfd0b15365a5cd54b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 10 Jun 2021 01:22:46 +0300 Subject: [PATCH 031/154] Update CMakeLists.txt --- CMakeLists.txt | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c7c1452..03f8da9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,11 +2,8 @@ # 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) +cmake_minimum_required(VERSION 3.5...3.20) +project(boost_array VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) add_library(boost_array INTERFACE) add_library(Boost::array ALIAS boost_array) @@ -21,4 +18,3 @@ target_link_libraries(boost_array Boost::static_assert Boost::throw_exception ) - From e384e3780ba1a86425c138ecd47761ad11050615 Mon Sep 17 00:00:00 2001 From: sdarwin Date: Fri, 30 Jul 2021 16:10:15 +0000 Subject: [PATCH 032/154] Update GitHub Actions CI file --- .github/workflows/ci.yml | 57 +++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b993cce1..19855c3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,8 @@ jobs: buildtype: "96ad197d74-2319b6d45f" packages: "" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "g++" sources: "" llvm_os: "" @@ -31,7 +32,8 @@ jobs: buildtype: "boost" packages: "" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "g++" sources: "" llvm_os: "" @@ -43,7 +45,8 @@ jobs: buildtype: "boost" packages: "g++-4.7" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "g++-4.7" sources: "" llvm_os: "" @@ -55,7 +58,8 @@ jobs: buildtype: "boost" packages: "g++-4.8" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "g++-4.8" sources: "" llvm_os: "" @@ -67,7 +71,8 @@ jobs: buildtype: "boost" packages: "g++-4.9" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "g++-4.9" sources: "" llvm_os: "" @@ -79,7 +84,8 @@ jobs: buildtype: "boost" packages: "g++-5" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "g++-5" sources: "" llvm_os: "" @@ -91,7 +97,8 @@ jobs: buildtype: "boost" packages: "g++-6" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "g++-6" sources: "" llvm_os: "" @@ -103,7 +110,8 @@ jobs: buildtype: "boost" packages: "g++-7" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "g++-7" sources: "" llvm_os: "" @@ -115,7 +123,7 @@ jobs: buildtype: "boost" packages: "" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-18.04" cxx: "clang++" sources: "" llvm_os: "" @@ -127,7 +135,8 @@ jobs: buildtype: "boost" packages: "clang-3.5 libstdc++-4.9-dev" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "clang++-3.5" sources: "" llvm_os: "precise" @@ -139,7 +148,8 @@ jobs: buildtype: "boost" packages: "clang-3.6" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "clang++-3.6" sources: "" llvm_os: "precise" @@ -151,7 +161,8 @@ jobs: buildtype: "boost" packages: "clang-3.7" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "clang++-3.7" sources: "" llvm_os: "precise" @@ -163,7 +174,8 @@ jobs: buildtype: "boost" packages: "clang-3.8 libstdc++-4.9-dev" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "clang++-3.8" sources: "" llvm_os: "precise" @@ -175,7 +187,8 @@ jobs: buildtype: "boost" packages: "clang-3.9 libstdc++-4.9-dev" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "clang++-3.9" sources: "" llvm_os: "precise" @@ -187,7 +200,8 @@ jobs: buildtype: "boost" packages: "clang-4.0" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "clang++-4.0" sources: "" llvm_os: "xenial" @@ -199,7 +213,8 @@ jobs: buildtype: "boost" packages: "clang-5.0" packages_to_remove: "" - os: "ubuntu-16.04" + os: "ubuntu-20.04" + container: "ubuntu:16.04" cxx: "clang++-5.0" sources: "" llvm_os: "xenial" @@ -215,6 +230,16 @@ jobs: - name: Check if running in container if: matrix.container != '' run: echo "GHA_CONTAINER=${{ matrix.container }}" >> $GITHUB_ENV + - name: If running in container, upgrade packages + if: matrix.container != '' + run: | + apt-get -o Acquire::Retries=3 update && DEBIAN_FRONTEND=noninteractive apt-get -y install tzdata && apt-get -o Acquire::Retries=3 install -y sudo software-properties-common wget curl apt-transport-https make apt-file sudo unzip libssl-dev build-essential autotools-dev autoconf automake g++ libc++-helpers python ruby cpio gcc-multilib g++-multilib pkgconf python3 ccache libpython-dev + sudo apt-add-repository ppa:git-core/ppa + sudo apt-get -o Acquire::Retries=3 update && apt-get -o Acquire::Retries=3 -y install git + python_version=$(python3 -c 'import sys; print("{0.major}.{0.minor}".format(sys.version_info))') + sudo wget https://bootstrap.pypa.io/pip/$python_version/get-pip.py + sudo python3 get-pip.py + sudo /usr/local/bin/pip install cmake - uses: actions/checkout@v2 From a3f15458b86ba8da392330fe184bc66619abcb87 Mon Sep 17 00:00:00 2001 From: Baoshuo Ren Date: Mon, 25 Jul 2022 18:03:08 +0800 Subject: [PATCH 033/154] chore: bump macos runner version GitHub Action is sunsetting the macOS 10.15 Actions runner. It will stop working intermittently until being completely removed by 2022-8-30: https://github.blog/changelog/2022-07-20-github-actions-the-macos-10-15-actions-runner-image-is-being-deprecated-and-will-be-removed-by-8-30-22 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19855c3a..1d8d99e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -345,7 +345,7 @@ jobs: - name: "TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,1 Job 16" buildtype: "boost" packages: "" - os: "macos-10.15" + os: "macos-11" cxx: "clang++" sources: "" llvm_os: "" From 4647fc7095b41ce0db310354d280741c52714b32 Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 23 Aug 2022 15:55:19 +0100 Subject: [PATCH 034/154] refactor: use core/swap.hpp over boost/swap.hpp The later is deprecated: ```cpp ifndef BOOST_SWAP_HPP define BOOST_SWAP_HPP // The header file at this path is deprecated; // use boost/core/swap.hpp instead. include endif ``` --- include/boost/array.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index a32d1e99..f047063d 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -44,8 +44,8 @@ #include #include #include +#include #include -#include #include #include From c774c93b3b9e95812075450bb4a639d981c54716 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sun, 3 Sep 2023 00:05:33 +0300 Subject: [PATCH 035/154] Switch to boost::core::invoke_swap. boost::swap is deprecated and will be removed. Use boost::core::invoke_swap as a replacement. --- include/boost/array.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index f047063d..c75b39c5 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include @@ -156,7 +156,7 @@ namespace boost { // swap (note: linear complexity) void swap (array& y) { for (size_type i = 0; i < N; ++i) - boost::swap(elems[i],y.elems[i]); + boost::core::invoke_swap(elems[i],y.elems[i]); } // direct access to data (read-only) From b19ce675ad5486eb9acf0cccffd8766d87060422 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Sun, 3 Sep 2023 00:06:37 +0300 Subject: [PATCH 036/154] Trim trailing spaces. --- include/boost/array.hpp | 90 ++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index c75b39c5..02bd76db 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -33,11 +33,11 @@ #include -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -# pragma warning(push) +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(push) # pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe -# pragma warning(disable:4510) // boost::array' : default constructor could not be generated -# pragma warning(disable:4610) // warning C4610: class 'boost::array' can never be instantiated - user defined constructor required +# pragma warning(disable:4510) // boost::array' : default constructor could not be generated +# pragma warning(disable:4610) // warning C4610: class 'boost::array' can never be instantiated - user defined constructor required #endif #include @@ -75,7 +75,7 @@ namespace boost { iterator begin() { return elems; } const_iterator begin() const { return elems; } const_iterator cbegin() const { return elems; } - + iterator end() { return elems+N; } const_iterator end() const { return elems+N; } const_iterator cend() const { return elems+N; } @@ -84,9 +84,9 @@ namespace boost { #if !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; -#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) - typedef std::reverse_iterator reverse_iterator; +#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) + typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; #else @@ -112,39 +112,39 @@ namespace boost { } // operator[] - reference operator[](size_type i) - { - return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; + reference operator[](size_type i) + { + return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; } - - /*BOOST_CONSTEXPR*/ const_reference operator[](size_type i) const - { - return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; + + /*BOOST_CONSTEXPR*/ const_reference operator[](size_type i) const + { + return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; } // at() with range check reference at(size_type i) { return rangecheck(i), elems[i]; } /*BOOST_CONSTEXPR*/ const_reference at(size_type i) const { return rangecheck(i), elems[i]; } - + // front() and back() - reference front() - { - return elems[0]; + reference front() + { + return elems[0]; } - - BOOST_CONSTEXPR const_reference front() const + + BOOST_CONSTEXPR const_reference front() const { return elems[0]; } - - reference back() - { - return elems[N-1]; + + reference back() + { + return elems[N-1]; } - - BOOST_CONSTEXPR const_reference back() const - { - return elems[N-1]; + + BOOST_CONSTEXPR const_reference back() const + { + return elems[N-1]; } // size is constant @@ -213,9 +213,9 @@ namespace boost { #if !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; -#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) - typedef std::reverse_iterator reverse_iterator; +#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) + typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; #else @@ -301,7 +301,7 @@ namespace boost { // assign one value to all elements void assign (const T& value) { fill ( value ); } void fill (const T& ) {} - + // check range (may be private because it is static) static reference failed_rangecheck () { std::out_of_range e("attempt to access element of an empty array"); @@ -353,16 +353,16 @@ namespace boost { #if defined(__SUNPRO_CC) // Trac ticket #4757; the Sun Solaris compiler can't handle // syntax like 'T(&get_c_array(boost::array& arg))[N]' -// -// We can't just use this for all compilers, because the -// borland compilers can't handle this form. +// +// We can't just use this for all compilers, because the +// borland compilers can't handle this form. namespace detail { template struct c_array { typedef T type[N]; }; } - + // Specific for boost::array: simply returns its elems data member. template typename detail::c_array::type& get_c_array(boost::array& arg) @@ -383,7 +383,7 @@ namespace boost { { return arg.elems; } - + // Const version. template const T(&get_c_array(const boost::array& arg))[N] @@ -391,7 +391,7 @@ namespace boost { return arg.elems; } #endif - + #if 0 // Overload for std::array, assuming that std::array will have // explicit conversion functions as discussed at the WG21 meeting @@ -401,7 +401,7 @@ namespace boost { { return static_cast(arg); } - + // Const version. template const T(&get_c_array(const std::array& arg))[N] @@ -423,7 +423,7 @@ namespace boost { BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" ); return arr[Idx]; } - + template const T &get(const boost::array &arr) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(const boost::array &) index out of range" ); @@ -440,7 +440,7 @@ namespace std { BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(boost::array &) index out of range" ); return arr[Idx]; } - + template const T &get(const boost::array &arr) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(const boost::array &) index out of range" ); @@ -449,8 +449,8 @@ namespace std { } #endif -#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) -# pragma warning(pop) -#endif +#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) +# pragma warning(pop) +#endif #endif /*BOOST_ARRAY_HPP*/ From 3dfc2a089c33a0ed4969d11500428c6e70fa47d6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 8 Sep 2023 09:35:15 +0300 Subject: [PATCH 037/154] Update ci.yml --- .github/workflows/ci.yml | 924 +++++++++++++++++++++++---------------- 1 file changed, 557 insertions(+), 367 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d8d99e0..307c24b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: GitHub Actions CI +name: CI on: pull_request: @@ -6,10 +6,10 @@ on: branches: - master - develop - - githubactions* - feature/** - - fix/** - - pr/** + +env: + UBSAN_OPTIONS: print_stacktrace=1 jobs: posix: @@ -17,405 +17,595 @@ jobs: fail-fast: false matrix: include: - - name: "TEST_CMAKE=TRUE Job 0" - buildtype: "96ad197d74-2319b6d45f" - packages: "" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "g++" - sources: "" - llvm_os: "" - llvm_ver: "" - test_cmake: "TRUE" - - name: "TOOLSET=gcc COMPILER=g++ CXXSTD=03,11 Job 1" - buildtype: "boost" - packages: "" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "g++" - sources: "" - llvm_os: "" - llvm_ver: "" - toolset: "gcc" - compiler: "g++" - cxxstd: "03,11" - - name: "TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11 Job 2" - buildtype: "boost" - packages: "g++-4.7" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "g++-4.7" - sources: "" - llvm_os: "" - llvm_ver: "" - toolset: "gcc" - compiler: "g++-4.7" - cxxstd: "03,11" - - name: "TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11 Job 3" - buildtype: "boost" - packages: "g++-4.8" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "g++-4.8" - sources: "" - llvm_os: "" - llvm_ver: "" - toolset: "gcc" - compiler: "g++-4.8" + - toolset: gcc-4.8 cxxstd: "03,11" - - name: "TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11 Job 4" - buildtype: "boost" - packages: "g++-4.9" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "g++-4.9" - sources: "" - llvm_os: "" - llvm_ver: "" - toolset: "gcc" - compiler: "g++-4.9" - cxxstd: "03,11" - - name: "TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z Job 5" - buildtype: "boost" - packages: "g++-5" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "g++-5" - sources: "" - llvm_os: "" - llvm_ver: "" - toolset: "gcc" - compiler: "g++-5" + os: ubuntu-latest + container: ubuntu:18.04 + install: g++-4.8-multilib + address-model: 32,64 + - toolset: gcc-5 cxxstd: "03,11,14,1z" - - name: "TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z Job 6" - buildtype: "boost" - packages: "g++-6" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "g++-6" - sources: "" - llvm_os: "" - llvm_ver: "" - toolset: "gcc" - compiler: "g++-6" + os: ubuntu-latest + container: ubuntu:18.04 + install: g++-5-multilib + address-model: 32,64 + - toolset: gcc-6 cxxstd: "03,11,14,1z" - - name: "TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 Job 7" - buildtype: "boost" - packages: "g++-7" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "g++-7" - sources: "" - llvm_os: "" - llvm_ver: "" - toolset: "gcc" - compiler: "g++-7" + os: ubuntu-latest + container: ubuntu:18.04 + install: g++-6-multilib + address-model: 32,64 + - toolset: gcc-7 cxxstd: "03,11,14,17" - - name: "TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 Job 8" - buildtype: "boost" - packages: "" - packages_to_remove: "" - os: "ubuntu-18.04" - cxx: "clang++" - sources: "" - llvm_os: "" - llvm_ver: "" - toolset: "clang" - compiler: "clang++" - cxxstd: "03,11" - - name: "TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03, Job 9" - buildtype: "boost" - packages: "clang-3.5 libstdc++-4.9-dev" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "clang++-3.5" - sources: "" - llvm_os: "precise" - llvm_ver: "3.5" - toolset: "clang" - compiler: "clang++-3.5" + os: ubuntu-20.04 + install: g++-7-multilib + address-model: 32,64 + - toolset: gcc-8 + cxxstd: "03,11,14,17,2a" + os: ubuntu-20.04 + install: g++-8-multilib + address-model: 32,64 + - toolset: gcc-9 + cxxstd: "03,11,14,17,2a" + os: ubuntu-20.04 + install: g++-9-multilib + address-model: 32,64 + - toolset: gcc-10 + cxxstd: "03,11,14,17,2a" + os: ubuntu-22.04 + install: g++-10-multilib + address-model: 32,64 + - toolset: gcc-11 + cxxstd: "03,11,14,17,20" + os: ubuntu-22.04 + install: g++-11-multilib + address-model: 32,64 + - toolset: gcc-12 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-22.04 + install: g++-12-multilib + address-model: 32,64 + - toolset: gcc-13 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-latest + container: ubuntu:23.04 + install: g++-13-multilib + address-model: 32,64 + - toolset: clang + compiler: clang++-3.9 cxxstd: "03,11,14" - - name: "TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03, Job 10" - buildtype: "boost" - packages: "clang-3.6" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "clang++-3.6" - sources: "" - llvm_os: "precise" - llvm_ver: "3.6" - toolset: "clang" - compiler: "clang++-3.6" + os: ubuntu-latest + container: ubuntu:18.04 + install: clang-3.9 + - toolset: clang + compiler: clang++-4.0 cxxstd: "03,11,14" - - name: "TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03, Job 11" - buildtype: "boost" - packages: "clang-3.7" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "clang++-3.7" - sources: "" - llvm_os: "precise" - llvm_ver: "3.7" - toolset: "clang" - compiler: "clang++-3.7" - cxxstd: "03,11,14" - - name: "TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03, Job 12" - buildtype: "boost" - packages: "clang-3.8 libstdc++-4.9-dev" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "clang++-3.8" - sources: "" - llvm_os: "precise" - llvm_ver: "3.8" - toolset: "clang" - compiler: "clang++-3.8" - cxxstd: "03,11,14" - - name: "TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03, Job 13" - buildtype: "boost" - packages: "clang-3.9 libstdc++-4.9-dev" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "clang++-3.9" - sources: "" - llvm_os: "precise" - llvm_ver: "3.9" - toolset: "clang" - compiler: "clang++-3.9" - cxxstd: "03,11,14" - - name: "TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03, Job 14" - buildtype: "boost" - packages: "clang-4.0" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "clang++-4.0" - sources: "" - llvm_os: "xenial" - llvm_ver: "4.0" - toolset: "clang" - compiler: "clang++-4.0" - cxxstd: "03,11,14" - - name: "TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03, Job 15" - buildtype: "boost" - packages: "clang-5.0" - packages_to_remove: "" - os: "ubuntu-20.04" - container: "ubuntu:16.04" - cxx: "clang++-5.0" - sources: "" - llvm_os: "xenial" - llvm_ver: "5.0" - toolset: "clang" - compiler: "clang++-5.0" + os: ubuntu-latest + container: ubuntu:18.04 + install: clang-4.0 + - toolset: clang + compiler: clang++-5.0 cxxstd: "03,11,14,1z" + os: ubuntu-latest + container: ubuntu:18.04 + install: clang-5.0 + - toolset: clang + compiler: clang++-6.0 + cxxstd: "03,11,14,17" + os: ubuntu-20.04 + install: clang-6.0 + - toolset: clang + compiler: clang++-7 + cxxstd: "03,11,14,17" + os: ubuntu-20.04 + install: clang-7 + - toolset: clang + compiler: clang++-8 + cxxstd: "03,11,14,17" + os: ubuntu-20.04 + install: clang-8 + - toolset: clang + compiler: clang++-9 + cxxstd: "03,11,14,17,2a" + os: ubuntu-20.04 + install: clang-9 + - toolset: clang + compiler: clang++-10 + cxxstd: "03,11,14,17,2a" + os: ubuntu-20.04 + - toolset: clang + compiler: clang++-11 + cxxstd: "03,11,14,17,2a" + os: ubuntu-20.04 + - toolset: clang + compiler: clang++-12 + cxxstd: "03,11,14,17,20" + os: ubuntu-20.04 + - toolset: clang + compiler: clang++-13 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-22.04 + install: clang-13 + - toolset: clang + compiler: clang++-14 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-22.04 + install: clang-14 + - toolset: clang + compiler: clang++-15 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-22.04 + install: clang-15 + - toolset: clang + compiler: clang++-16 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-latest + container: ubuntu:23.04 + install: clang-16 + - toolset: clang + cxxstd: "03,11,14,17,2a" + os: macos-11 + - toolset: clang + cxxstd: "03,11,14,17,20,2b" + os: macos-12 + - toolset: clang + cxxstd: "03,11,14,17,20,2b" + os: macos-13 - runs-on: ${{ matrix.os }} - container: ${{ matrix.container }} + runs-on: ${{matrix.os}} + container: ${{matrix.container}} - steps: - - name: Check if running in container - if: matrix.container != '' - run: echo "GHA_CONTAINER=${{ matrix.container }}" >> $GITHUB_ENV - - name: If running in container, upgrade packages - if: matrix.container != '' - run: | - apt-get -o Acquire::Retries=3 update && DEBIAN_FRONTEND=noninteractive apt-get -y install tzdata && apt-get -o Acquire::Retries=3 install -y sudo software-properties-common wget curl apt-transport-https make apt-file sudo unzip libssl-dev build-essential autotools-dev autoconf automake g++ libc++-helpers python ruby cpio gcc-multilib g++-multilib pkgconf python3 ccache libpython-dev - sudo apt-add-repository ppa:git-core/ppa - sudo apt-get -o Acquire::Retries=3 update && apt-get -o Acquire::Retries=3 -y install git - python_version=$(python3 -c 'import sys; print("{0.major}.{0.minor}".format(sys.version_info))') - sudo wget https://bootstrap.pypa.io/pip/$python_version/get-pip.py - sudo python3 get-pip.py - sudo /usr/local/bin/pip install cmake - - - uses: actions/checkout@v2 - - - name: linux + defaults: + run: shell: bash - env: - CXX: ${{ matrix.cxx }} - SOURCES: ${{ matrix.sources }} - LLVM_OS: ${{ matrix.llvm_os }} - LLVM_VER: ${{ matrix.llvm_ver }} - PACKAGES: ${{ matrix.packages }} - PACKAGES_TO_REMOVE: ${{ matrix.packages_to_remove }} - JOB_BUILDTYPE: ${{ matrix.buildtype }} - TEST_CMAKE: ${{ matrix.test_cmake }} - TOOLSET: ${{ matrix.toolset }} - COMPILER: ${{ matrix.compiler }} - CXXSTD: ${{ matrix.cxxstd }} - TRAVIS_BRANCH: ${{ github.base_ref }} - TRAVIS_OS_NAME: "linux" - run: | - echo '==================================> SETUP' - echo '==================================> PACKAGES' - set -e - if [ -n "$PACKAGES_TO_REMOVE" ]; then sudo apt-get purge -y $PACKAGES_TO_REMOVE; fi - echo ">>>>> APT: REPO.." - for i in {1..3}; do sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test" && break || sleep 2; done - - if test -n "${LLVM_OS}" ; then - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - if test -n "${LLVM_VER}" ; then - sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS}-${LLVM_VER} main" - else - # Snapshot (i.e. trunk) build of clang - sudo -E apt-add-repository "deb http://apt.llvm.org/${LLVM_OS}/ llvm-toolchain-${LLVM_OS} main" - fi - fi - echo ">>>>> APT: UPDATE.." - sudo -E apt-get -o Acquire::Retries=3 update - if test -n "${SOURCES}" ; then - echo ">>>>> APT: INSTALL SOURCES.." - for SOURCE in $SOURCES; do - sudo -E apt-add-repository ppa:$SOURCE - done - fi - echo ">>>>> APT: INSTALL ${PACKAGES}.." - sudo -E DEBIAN_FRONTEND=noninteractive apt-get -o Acquire::Retries=3 -y --no-install-suggests --no-install-recommends install ${PACKAGES} - - echo '==================================> INSTALL AND COMPILE' - set -e - export TRAVIS_BUILD_DIR=$(pwd) - export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')} - export VCS_COMMIT_ID=$GITHUB_SHA - export GIT_COMMIT=$GITHUB_SHA - export REPO_NAME=$(basename $GITHUB_REPOSITORY) - export USER=$(whoami) - export CC=${CC:-gcc} - export PATH=~/.local/bin:/usr/local/bin:$PATH - - if [ "$JOB_BUILDTYPE" == "96ad197d74-2319b6d45f" ]; then - - echo '==================================> INSTALL' - - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/assert.git ../assert - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/config.git ../config - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/core.git ../core - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/static_assert.git ../static_assert - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/throw_exception.git ../throw_exception - - echo '==================================> SCRIPT' + steps: + - uses: actions/checkout@v3 + + - name: Setup container environment + if: matrix.container + run: | + apt-get update + apt-get -y install sudo python3 git g++ + + - name: Install packages + if: matrix.install + run: | + sudo apt-get update + sudo apt-get -y install ${{matrix.install}} + + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH + cd .. + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + git submodule update --init tools/boostdep + python3 tools/boostdep/depinst/depinst.py -I examples --git_args "--jobs 3" $LIBRARY + ./bootstrap.sh + ./b2 -d0 headers + + - name: Create user-config.jam + if: matrix.compiler + run: | + echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam + + - name: Run tests + run: | + cd ../boost-root + export ADDRMD=${{matrix.address-model}} + ./b2 -j3 --verbose-test libs/$LIBRARY/test//hash_info toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} ${ADDRMD:+address-model=$ADDRMD} variant=debug,release + ./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} ${ADDRMD:+address-model=$ADDRMD} variant=debug,release + + windows: + strategy: + fail-fast: false + matrix: + include: + - toolset: msvc-14.0 + cxxstd: 14,latest + addrmd: 32,64 + os: windows-2019 + - toolset: msvc-14.2 + cxxstd: "14,17,20,latest" + addrmd: 32,64 + os: windows-2019 + - toolset: msvc-14.3 + cxxstd: "14,17,20,latest" + addrmd: 32,64 + os: windows-2022 + - toolset: clang-win + cxxstd: "14,17,latest" + addrmd: 32,64 + os: windows-2022 + - toolset: gcc + cxxstd: "03,11,14,17,2a" + addrmd: 64 + os: windows-2019 + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + + - name: Setup Boost + shell: cmd + run: | + echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY% + for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi + echo LIBRARY: %LIBRARY% + echo LIBRARY=%LIBRARY%>>%GITHUB_ENV% + echo GITHUB_BASE_REF: %GITHUB_BASE_REF% + echo GITHUB_REF: %GITHUB_REF% + if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF% + set BOOST_BRANCH=develop + for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master + echo BOOST_BRANCH: %BOOST_BRANCH% + cd .. + git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py -I examples --git_args "--jobs 3" %LIBRARY% + cmd /c bootstrap + b2 -d0 headers + + - name: Run tests + shell: cmd + run: | + cd ../boost-root + b2 -j3 --verbose-test libs/%LIBRARY%/test//hash_info toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker + b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker + + posix-cmake-subdir: + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-20.04 + - os: ubuntu-22.04 + - os: macos-11 + - os: macos-12 + - os: macos-13 + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + + - name: Install packages + if: matrix.install + run: sudo apt-get -y install ${{matrix.install}} + + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH + cd .. + git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + + - name: Use library with add_subdirectory + run: | + cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test mkdir __build__ && cd __build__ - cmake ../test/test_cmake + cmake .. cmake --build . + ctest --output-on-failure --no-tests=error + + posix-cmake-install: + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-20.04 + - os: ubuntu-22.04 + - os: macos-11 + - os: macos-12 + - os: macos-13 - elif [ "$JOB_BUILDTYPE" == "boost" ]; then + runs-on: ${{matrix.os}} - echo '==================================> INSTALL' + steps: + - uses: actions/checkout@v3 + + - name: Install packages + if: matrix.install + run: sudo apt-get -y install ${{matrix.install}} - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH cd .. git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root cd boost-root - git submodule update --init tools/build - git submodule update --init libs/config + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY git submodule update --init tools/boostdep - cp -r $TRAVIS_BUILD_DIR/* libs/array - python tools/boostdep/depinst/depinst.py array - ./bootstrap.sh - ./b2 headers + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY - echo '==================================> SCRIPT' + - name: Configure + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local .. + + - name: Install + run: | + cd ../boost-root/__build__ + cmake --build . --target install - echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam - ./b2 -j 3 libs/array/test toolset=$TOOLSET cxxstd=$CXXSTD + - name: Use the installed library + run: | + cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__ + cmake -DCMAKE_INSTALL_PREFIX=~/.local .. + cmake --build . + ctest --output-on-failure --no-tests=error - fi - osx: + posix-cmake-test: strategy: fail-fast: false matrix: include: - - name: "TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,1 Job 16" - buildtype: "boost" - packages: "" - os: "macos-11" - cxx: "clang++" - sources: "" - llvm_os: "" - llvm_ver: "" - xcode_version: 11.7 - toolset: "clang" - compiler: "clang++" - cxxstd: "03,11,14,1z" + - os: ubuntu-20.04 + - os: ubuntu-22.04 + - os: macos-11 + - os: macos-12 + - os: macos-13 - runs-on: ${{ matrix.os }} + runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - name: Set DEVELOPER_DIR - if: matrix.xcode_version != '' - run: echo "DEVELOPER_DIR=/Applications/Xcode_${{ matrix.xcode_version }}.app/Contents/Developer" >> $GITHUB_ENV - - name: Test DEVELOPER_DIR - run: echo $DEVELOPER_DIR + - name: Install packages + if: matrix.install + run: sudo apt-get -y install ${{matrix.install}} - - name: "osx" - shell: bash - env: - CXX: ${{ matrix.cxx }} - SOURCES: ${{ matrix.sources }} - LLVM_OS: ${{ matrix.llvm_os }} - LLVM_VER: ${{ matrix.llvm_ver }} - PACKAGES: ${{ matrix.packages }} - JOB_BUILDTYPE: ${{ matrix.buildtype }} - TEST_CMAKE: ${{ matrix.test_cmake }} - TOOLSET: ${{ matrix.toolset }} - COMPILER: ${{ matrix.compiler }} - CXXSTD: ${{ matrix.cxxstd }} - TRAVIS_BRANCH: ${{ github.base_ref }} - TRAVIS_OS_NAME: "osx" - run: | - echo '==================================> SETUP' - set -e - sudo mv /Library/Developer/CommandLineTools /Library/Developer/CommandLineTools.bck - echo '==================================> PACKAGES' - echo '==================================> INSTALL AND COMPILE' - set -e - export TRAVIS_BUILD_DIR=$(pwd) - export TRAVIS_BRANCH=${TRAVIS_BRANCH:-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')} - export VCS_COMMIT_ID=$GITHUB_SHA - export GIT_COMMIT=$GITHUB_SHA - export REPO_NAME=$(basename $GITHUB_REPOSITORY) - export USER=$(whoami) - export CC=${CC:-gcc} - export PATH=~/.local/bin:/usr/local/bin:$PATH - - if [ "$JOB_BUILDTYPE" == "boost" ]; then - - echo '==================================> INSTALL' - - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true + - name: Setup Boost + run: | + echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY + LIBRARY=${GITHUB_REPOSITORY#*/} + echo LIBRARY: $LIBRARY + echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV + echo GITHUB_BASE_REF: $GITHUB_BASE_REF + echo GITHUB_REF: $GITHUB_REF + REF=${GITHUB_BASE_REF:-$GITHUB_REF} + REF=${REF#refs/heads/} + echo REF: $REF + BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true + echo BOOST_BRANCH: $BOOST_BRANCH cd .. git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root cd boost-root - git submodule update --init tools/build - git submodule update --init libs/config + cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY git submodule update --init tools/boostdep - cp -r $TRAVIS_BUILD_DIR/* libs/array - python tools/boostdep/depinst/depinst.py array - ./bootstrap.sh - ./b2 headers + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY + + - name: Configure + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON .. + + - name: Build tests + run: | + cd ../boost-root/__build__ + cmake --build . --target tests + + - name: Run tests + run: | + cd ../boost-root/__build__ + ctest --output-on-failure --no-tests=error + + windows-cmake-subdir: + strategy: + fail-fast: false + matrix: + include: + - os: windows-2019 + - os: windows-2022 + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + + - name: Setup Boost + shell: cmd + run: | + echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY% + for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi + echo LIBRARY: %LIBRARY% + echo LIBRARY=%LIBRARY%>>%GITHUB_ENV% + echo GITHUB_BASE_REF: %GITHUB_BASE_REF% + echo GITHUB_REF: %GITHUB_REF% + if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF% + set BOOST_BRANCH=develop + for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master + echo BOOST_BRANCH: %BOOST_BRANCH% + cd .. + git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% - echo '==================================> SCRIPT' + - name: Use library with add_subdirectory (Debug) + shell: cmd + run: | + cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test + mkdir __build__ && cd __build__ + cmake .. + cmake --build . --config Debug + ctest --output-on-failure --no-tests=error -C Debug - echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam - ./b2 -j 3 libs/array/test toolset=$TOOLSET cxxstd=$CXXSTD + - name: Use library with add_subdirectory (Release) + shell: cmd + run: | + cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__ + cmake --build . --config Release + ctest --output-on-failure --no-tests=error -C Release - fi + windows-cmake-install: + strategy: + fail-fast: false + matrix: + include: + - os: windows-2019 + - os: windows-2022 + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + + - name: Setup Boost + shell: cmd + run: | + echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY% + for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi + echo LIBRARY: %LIBRARY% + echo LIBRARY=%LIBRARY%>>%GITHUB_ENV% + echo GITHUB_BASE_REF: %GITHUB_BASE_REF% + echo GITHUB_REF: %GITHUB_REF% + if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF% + set BOOST_BRANCH=develop + for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master + echo BOOST_BRANCH: %BOOST_BRANCH% + cd .. + git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + + - name: Configure + shell: cmd + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix .. + + - name: Install (Debug) + shell: cmd + run: | + cd ../boost-root/__build__ + cmake --build . --target install --config Debug + + - name: Install (Release) + shell: cmd + run: | + cd ../boost-root/__build__ + cmake --build . --target install --config Release + + - name: Use the installed library (Debug) + shell: cmd + run: | + cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__ + cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix .. + cmake --build . --config Debug + ctest --output-on-failure --no-tests=error -C Debug + + - name: Use the installed library (Release) + shell: cmd + run: | + cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__ + cmake --build . --config Release + ctest --output-on-failure --no-tests=error -C Release + + windows-cmake-test: + strategy: + fail-fast: false + matrix: + include: + - os: windows-2019 + - os: windows-2022 + + runs-on: ${{matrix.os}} + + steps: + - uses: actions/checkout@v3 + + - name: Setup Boost + shell: cmd + run: | + echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY% + for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi + echo LIBRARY: %LIBRARY% + echo LIBRARY=%LIBRARY%>>%GITHUB_ENV% + echo GITHUB_BASE_REF: %GITHUB_BASE_REF% + echo GITHUB_REF: %GITHUB_REF% + if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF% + set BOOST_BRANCH=develop + for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master + echo BOOST_BRANCH: %BOOST_BRANCH% + cd .. + git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root + cd boost-root + xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\ + git submodule update --init tools/boostdep + python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY% + + - name: Configure + shell: cmd + run: | + cd ../boost-root + mkdir __build__ && cd __build__ + cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON .. + + - name: Build tests (Debug) + shell: cmd + run: | + cd ../boost-root/__build__ + cmake --build . --target tests --config Debug + + - name: Run tests (Debug) + shell: cmd + run: | + cd ../boost-root/__build__ + ctest --output-on-failure --no-tests=error -C Debug + + - name: Build tests (Release) + shell: cmd + run: | + cd ../boost-root/__build__ + cmake --build . --target tests --config Release + + - name: Run tests (Release) + shell: cmd + run: | + cd ../boost-root/__build__ + ctest --output-on-failure --no-tests=error -C Release From ec72fd87a1b1b8b3357fe9bc955da85fac894e24 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 8 Sep 2023 09:36:13 +0300 Subject: [PATCH 038/154] Regenerate CMakeLists.txt --- CMakeLists.txt | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03f8da9f..6727882e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,10 @@ -# Copyright 2018 Mike Dev +# Generated by `boostdep --cmake array` +# Copyright 2020, 2021 Peter Dimov # 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 +# https://www.boost.org/LICENSE_1_0.txt cmake_minimum_required(VERSION 3.5...3.20) + project(boost_array VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) add_library(boost_array INTERFACE) @@ -11,10 +13,16 @@ 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 + INTERFACE + Boost::assert + Boost::config + Boost::core + Boost::static_assert + Boost::throw_exception ) + +if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") + + add_subdirectory(test) + +endif() From 8ad6749d4ad281a309047800950cf9a32147c5fa Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 8 Sep 2023 09:38:28 +0300 Subject: [PATCH 039/154] Update test/Jamfile --- test/Jamfile.v2 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 4c29720e..997967a1 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -2,17 +2,17 @@ #~ 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 ] - ; +import testing ; + +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 ; From bdc9ff1e2494a6b8656fd3a04f1d1e6941bedee6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 8 Sep 2023 09:47:09 +0300 Subject: [PATCH 040/154] Add CMake tests --- test/CMakeLists.txt | 12 ++++++++++++ test/Jamfile.v2 | 2 ++ test/cmake_install_test/CMakeLists.txt | 17 +++++++++++++++++ test/cmake_subdir_test/CMakeLists.txt | 23 +++++++++++++++++++++++ test/quick.cpp | 11 +++++++++++ test/test_cmake/CMakeLists.txt | 22 ---------------------- test/test_cmake/main.cpp | 5 ----- 7 files changed, 65 insertions(+), 27 deletions(-) create mode 100644 test/CMakeLists.txt create mode 100644 test/cmake_install_test/CMakeLists.txt create mode 100644 test/cmake_subdir_test/CMakeLists.txt create mode 100644 test/quick.cpp delete mode 100644 test/test_cmake/CMakeLists.txt delete mode 100644 test/test_cmake/main.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..81ccd27e --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright 2018, 2019, 2021, 2022 Peter Dimov +# 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(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST) + +if(HAVE_BOOST_TEST) + +boost_test_jamfile(FILE Jamfile.v2 + LINK_LIBRARIES Boost::array Boost::container_hash Boost::core) + +endif() diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 997967a1..bab406ab 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -16,3 +16,5 @@ run array7.cpp ; compile-fail array_getfail1.cpp ; compile-fail array_getfail2.cpp ; run array_hash.cpp ; + +run quick.cpp ; diff --git a/test/cmake_install_test/CMakeLists.txt b/test/cmake_install_test/CMakeLists.txt new file mode 100644 index 00000000..0b56a908 --- /dev/null +++ b/test/cmake_install_test/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright 2018, 2019, 2021 Peter Dimov +# 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 + +cmake_minimum_required(VERSION 3.5...3.20) + +project(cmake_install_test LANGUAGES CXX) + +find_package(boost_array REQUIRED) + +add_executable(quick ../quick.cpp) +target_link_libraries(quick Boost::array) + +enable_testing() +add_test(quick quick) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/test/cmake_subdir_test/CMakeLists.txt b/test/cmake_subdir_test/CMakeLists.txt new file mode 100644 index 00000000..ea0eae9d --- /dev/null +++ b/test/cmake_subdir_test/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright 2018, 2019, 2021 Peter Dimov +# 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 + +cmake_minimum_required(VERSION 3.5...3.20) + +project(cmake_subdir_test LANGUAGES CXX) + +add_subdirectory(../.. boostorg/array) + +add_subdirectory(../../../assert boostorg/assert) +add_subdirectory(../../../config boostorg/config) +add_subdirectory(../../../core boostorg/core) +add_subdirectory(../../../static_assert boostorg/static_assert) +add_subdirectory(../../../throw_exception boostorg/throw_exception) + +add_executable(quick ../quick.cpp) +target_link_libraries(quick Boost::array) + +enable_testing() +add_test(quick quick) + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $) diff --git a/test/quick.cpp b/test/quick.cpp new file mode 100644 index 00000000..c59a2c64 --- /dev/null +++ b/test/quick.cpp @@ -0,0 +1,11 @@ +// Copyright 2023 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include + +int main() +{ + boost::array a = {{ 0, 1 }}; + return a[0]; +} diff --git a/test/test_cmake/CMakeLists.txt b/test/test_cmake/CMakeLists.txt deleted file mode 100644 index d1bce85a..00000000 --- a/test/test_cmake/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# 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/test/test_cmake/main.cpp b/test/test_cmake/main.cpp deleted file mode 100644 index c2e0c905..00000000 --- a/test/test_cmake/main.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main() { - boost::array a{}; -} \ No newline at end of file From d9ccba09079229554a214f91b6eb11361797feb7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 8 Sep 2023 09:49:45 +0300 Subject: [PATCH 041/154] Update ci.yml --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 307c24b4..b74d0cd0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -205,7 +205,6 @@ jobs: run: | cd ../boost-root export ADDRMD=${{matrix.address-model}} - ./b2 -j3 --verbose-test libs/$LIBRARY/test//hash_info toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} ${ADDRMD:+address-model=$ADDRMD} variant=debug,release ./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} ${ADDRMD:+address-model=$ADDRMD} variant=debug,release windows: @@ -265,7 +264,6 @@ jobs: shell: cmd run: | cd ../boost-root - b2 -j3 --verbose-test libs/%LIBRARY%/test//hash_info toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker posix-cmake-subdir: From 36bba5af2d8fa43ea777b080129e0719e8eca655 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 11 Mar 2024 08:27:02 -0500 Subject: [PATCH 042/154] Make the library modular usable. --- build.jam | 24 ++++++++++++++++++++++++ test/Jamfile.v2 | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 build.jam diff --git a/build.jam b/build.jam new file mode 100644 index 00000000..853d7c7b --- /dev/null +++ b/build.jam @@ -0,0 +1,24 @@ +# Copyright René Ferdinand Rivera Morell 2023 +# 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) + +import project ; + +project /boost/array + : common-requirements + /boost/assert//boost_assert + /boost/config//boost_config + /boost/core//boost_core + /boost/static_assert//boost_static_assert + /boost/throw_exception//boost_throw_exception + include + ; + +explicit + [ alias boost_array ] + [ alias all : boost_array test ] + ; + +call-if : boost-library array + ; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index bab406ab..32cd9ae5 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -15,6 +15,6 @@ run array7.cpp ; # run array_constexpr.cpp ; compile-fail array_getfail1.cpp ; compile-fail array_getfail2.cpp ; -run array_hash.cpp ; +run array_hash.cpp /boost/container_hash//boost_container_hash ; run quick.cpp ; From d535c37a57024e87d74c446688f9e7153a03d148 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Fri, 29 Mar 2024 21:12:36 -0500 Subject: [PATCH 043/154] Switch to library requirements instead of source. As source puts extra source in install targets. --- build.jam | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build.jam b/build.jam index 853d7c7b..1d0d357a 100644 --- a/build.jam +++ b/build.jam @@ -7,11 +7,11 @@ import project ; project /boost/array : common-requirements - /boost/assert//boost_assert - /boost/config//boost_config - /boost/core//boost_core - /boost/static_assert//boost_static_assert - /boost/throw_exception//boost_throw_exception + /boost/assert//boost_assert + /boost/config//boost_config + /boost/core//boost_core + /boost/static_assert//boost_static_assert + /boost/throw_exception//boost_throw_exception include ; From 23f6b27c0d9916b9932baac898ae3009817a9153 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Thu, 11 Apr 2024 11:37:03 -0700 Subject: [PATCH 044/154] Add meaningless change to force rebuild --- test/array_constexpr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/array_constexpr.cpp b/test/array_constexpr.cpp index a3110057..48995c9f 100644 --- a/test/array_constexpr.cpp +++ b/test/array_constexpr.cpp @@ -3,7 +3,7 @@ * 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 From fe1e99eb31185d158f591c9f413e801bb3dcd564 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sun, 5 May 2024 09:00:00 -0500 Subject: [PATCH 045/154] Add requires-b2 check to top-level build file. --- build.jam | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.jam b/build.jam index 1d0d357a..d0ef6a74 100644 --- a/build.jam +++ b/build.jam @@ -3,6 +3,8 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +require-b2 5.1 ; + import project ; project /boost/array From 28d8d30b57b4f5af75ab9fe675a83e961f3fd570 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Fri, 14 Jun 2024 11:33:55 -0500 Subject: [PATCH 046/154] Bump B2 require to 5.2 --- build.jam | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.jam b/build.jam index d0ef6a74..0ec3655d 100644 --- a/build.jam +++ b/build.jam @@ -3,9 +3,7 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -require-b2 5.1 ; - -import project ; +require-b2 5.2 ; project /boost/array : common-requirements From fc104539948dad9495db128d5d540737a7a198ea Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sat, 20 Jul 2024 22:52:04 -0500 Subject: [PATCH 047/154] Update copyright dates. --- build.jam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.jam b/build.jam index 0ec3655d..abd53410 100644 --- a/build.jam +++ b/build.jam @@ -1,4 +1,4 @@ -# Copyright René Ferdinand Rivera Morell 2023 +# Copyright René Ferdinand Rivera Morell 2023-2024 # 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) From 40e2a2d4d804b6886332bc8c1487c99a9aa7ee97 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Tue, 23 Jul 2024 22:34:23 -0500 Subject: [PATCH 048/154] Move inter-lib dependencies to a project variable and into the build targets. --- build.jam | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/build.jam b/build.jam index abd53410..b927d267 100644 --- a/build.jam +++ b/build.jam @@ -5,20 +5,23 @@ require-b2 5.2 ; +constant boost_dependencies : + /boost/assert//boost_assert + /boost/config//boost_config + /boost/core//boost_core + /boost/static_assert//boost_static_assert + /boost/throw_exception//boost_throw_exception ; + project /boost/array : common-requirements - /boost/assert//boost_assert - /boost/config//boost_config - /boost/core//boost_core - /boost/static_assert//boost_static_assert - /boost/throw_exception//boost_throw_exception include ; explicit - [ alias boost_array ] + [ alias boost_array : : : : $(boost_dependencies) ] [ alias all : boost_array test ] ; call-if : boost-library array ; + From 78fb6a71ddd4b694cd9dd24188495f486f5962db Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sat, 27 Jul 2024 11:03:42 -0500 Subject: [PATCH 049/154] Adjust self dependencies as inter-lib deps no longer apply globally. --- test/Jamfile.v2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 32cd9ae5..cae4c9ea 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -4,6 +4,8 @@ import testing ; +project : requirements /boost/array//boost_array ; + run array0.cpp ; run array1.cpp ; run array2.cpp ; From f9c01c811a6897c7babd1a783494c017e4e626db Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 4 Nov 2024 03:31:57 +0200 Subject: [PATCH 050/154] Update ci.yml --- .github/workflows/ci.yml | 46 ++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b74d0cd0..055e3932 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,10 +67,14 @@ jobs: address-model: 32,64 - toolset: gcc-13 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-latest - container: ubuntu:23.04 + os: ubuntu-24.04 install: g++-13-multilib address-model: 32,64 + - toolset: gcc-14 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-24.04 + install: g++-14-multilib + address-model: 32,64 - toolset: clang compiler: clang++-3.9 cxxstd: "03,11,14" @@ -139,18 +143,27 @@ jobs: - toolset: clang compiler: clang++-16 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-latest - container: ubuntu:23.04 + os: ubuntu-24.04 install: clang-16 - toolset: clang - cxxstd: "03,11,14,17,2a" - os: macos-11 + compiler: clang++-17 + cxxstd: "03,11,14,17,20,2b" + os: ubuntu-24.04 + install: clang-17 - toolset: clang + compiler: clang++-18 cxxstd: "03,11,14,17,20,2b" - os: macos-12 + os: ubuntu-24.04 + install: clang-18 - toolset: clang cxxstd: "03,11,14,17,20,2b" os: macos-13 + - toolset: clang + cxxstd: "03,11,14,17,20,2b" + os: macos-14 + - toolset: clang + cxxstd: "03,11,14,17,20,2b" + os: macos-15 runs-on: ${{matrix.os}} container: ${{matrix.container}} @@ -160,6 +173,10 @@ jobs: shell: bash steps: + - name: Enable Node 16 + run: | + echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV + - uses: actions/checkout@v3 - name: Setup container environment @@ -273,9 +290,10 @@ jobs: include: - os: ubuntu-20.04 - os: ubuntu-22.04 - - os: macos-11 - - os: macos-12 + - os: ubuntu-24.04 - os: macos-13 + - os: macos-14 + - os: macos-15 runs-on: ${{matrix.os}} @@ -321,9 +339,10 @@ jobs: include: - os: ubuntu-20.04 - os: ubuntu-22.04 - - os: macos-11 - - os: macos-12 + - os: ubuntu-24.04 - os: macos-13 + - os: macos-14 + - os: macos-15 runs-on: ${{matrix.os}} @@ -379,9 +398,10 @@ jobs: include: - os: ubuntu-20.04 - os: ubuntu-22.04 - - os: macos-11 - - os: macos-12 + - os: ubuntu-24.04 - os: macos-13 + - os: macos-14 + - os: macos-15 runs-on: ${{matrix.os}} From 9a11abcb9f1346c0e19032a508000412fdb1d6d4 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 4 Nov 2024 03:43:06 +0200 Subject: [PATCH 051/154] Disable array_hash.cpp under C++03 --- test/Jamfile.v2 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index bab406ab..dde5c33b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -2,7 +2,10 @@ #~ 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) +require-b2 5.0.1 ; import testing ; +import-search /boost/config/checks ; +import config : requires ; run array0.cpp ; run array1.cpp ; @@ -12,9 +15,13 @@ 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 ; + +run array_hash.cpp + : : : [ requires cxx11_noexcept ] ; run quick.cpp ; From 9ea71dd967a5730df642b2e7eeac9287f56f0172 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 4 Nov 2024 03:45:50 +0200 Subject: [PATCH 052/154] Update ci.yml --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 055e3932..9aa3bafd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -253,7 +253,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Boost shell: cmd @@ -298,7 +298,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install packages if: matrix.install @@ -347,7 +347,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install packages if: matrix.install @@ -406,7 +406,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install packages if: matrix.install @@ -459,7 +459,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Boost shell: cmd @@ -508,7 +508,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Boost shell: cmd @@ -575,7 +575,7 @@ jobs: runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Boost shell: cmd From fed8935fdf8e4fe86800fe63426179a4a2fa226b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 4 Nov 2024 04:30:42 +0200 Subject: [PATCH 053/154] Add GCC 4.9 to ci.yml --- .github/workflows/ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9aa3bafd..d132519a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,12 @@ jobs: container: ubuntu:18.04 install: g++-4.8-multilib address-model: 32,64 + - toolset: gcc-4.9 + cxxstd: "03,11" + os: ubuntu-latest + container: ubuntu:16.04 + install: g++-4.9-multilib + address-model: 32,64 - toolset: gcc-5 cxxstd: "03,11,14,1z" os: ubuntu-latest @@ -209,7 +215,7 @@ jobs: cd boost-root cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY git submodule update --init tools/boostdep - python3 tools/boostdep/depinst/depinst.py -I examples --git_args "--jobs 3" $LIBRARY + python3 tools/boostdep/depinst/depinst.py -I examples $LIBRARY ./bootstrap.sh ./b2 -d0 headers From 22b8eebc3caf0aced1bf9cc6b087bfe4525d2664 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 16 Dec 2024 02:53:18 +0200 Subject: [PATCH 054/154] Apply Node20 workaround --- .github/workflows/ci.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d132519a..c5dea8ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -172,24 +172,32 @@ jobs: os: macos-15 runs-on: ${{matrix.os}} - container: ${{matrix.container}} + + container: + image: ${{matrix.container}} + volumes: + - /node20217:/node20217:rw,rshared + - ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }} defaults: run: shell: bash steps: - - name: Enable Node 16 - run: | - echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV - - - uses: actions/checkout@v3 - - name: Setup container environment if: matrix.container run: | apt-get update - apt-get -y install sudo python3 git g++ + apt-get -y install sudo python3 git g++ curl xz-utils + + - name: Install nodejs20glibc2.17 + if: ${{ startsWith( matrix.container, 'ubuntu:1' ) }} + run: | + curl -LO https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz + tar -xf node-v20.9.0-linux-x64-glibc-217.tar.xz --strip-components 1 -C /node20217 + ldd /__e/node20/bin/node + + - uses: actions/checkout@v4 - name: Install packages if: matrix.install From 99c3a4b9664a5e70cef034e3bc57d620675e5ff3 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Wed, 18 Dec 2024 15:31:13 -0800 Subject: [PATCH 055/154] refactor documentation to use asciidoc --- doc/.gitignore | 1 + doc/Jamfile.v2 | 23 +- doc/array.adoc | 28 ++ doc/array.xml | 639 -------------------------------- doc/array/copyright.adoc | 15 + doc/array/design_rationale.adoc | 43 +++ doc/array/information.adoc | 22 ++ doc/array/introduction.adoc | 37 ++ doc/array/reference.adoc | 418 +++++++++++++++++++++ 9 files changed, 574 insertions(+), 652 deletions(-) create mode 100644 doc/.gitignore create mode 100644 doc/array.adoc delete mode 100644 doc/array.xml create mode 100644 doc/array/copyright.adoc create mode 100644 doc/array/design_rationale.adoc create mode 100644 doc/array/information.adoc create mode 100644 doc/array/introduction.adoc create mode 100644 doc/array/reference.adoc diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 00000000..35b5e99a --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1 @@ +/html diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index b7f51b71..7087c6c7 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -1,19 +1,16 @@ #~ Copyright Marshall Clow 2013 +#~ Copyright Christian Mazakas 2024 #~ 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) -using boostbook ; +import asciidoctor ; -boostbook standalone - : array.xml - : boost.root=../../../.. ; +html array.html : array.adoc ; -############################################################################### -alias boostdoc - : array.xml - : - : - : ; -explicit boostdoc ; -alias boostrelease ; -explicit boostrelease ; +install html_ : array.html : html ; + +pdf array.pdf : array.adoc ; +explicit array.pdf ; + +install pdf_ : array.pdf : pdf ; +explicit pdf_ ; diff --git a/doc/array.adoc b/doc/array.adoc new file mode 100644 index 00000000..d6292b50 --- /dev/null +++ b/doc/array.adoc @@ -0,0 +1,28 @@ +//// +Copyright 2001-2004 Nicolai M. Josuttis +Copyright 2012 Marshall Clow +Copyright 2024 Christian Mazakas +Distributed under the Boost Software License, Version 1.0. +https://www.boost.org/LICENSE_1_0.txt +//// + +# Array +Nicolai M. Josuttis +:toc: left +:toclevels: 4 +:idprefix: +:docinfo: private-footer +:source-highlighter: rouge +:source-language: c++ +:sectanchors: + +:leveloffset: +1 + + +include::array/introduction.adoc[] +include::array/reference.adoc[] +include::array/design_rationale.adoc[] +include::array/information.adoc[] +include::array/copyright.adoc[] + +:leveloffset: -1 diff --git a/doc/array.xml b/doc/array.xml deleted file mode 100644 index 68ee5a31..00000000 --- a/doc/array.xml +++ /dev/null @@ -1,639 +0,0 @@ - - - - - - Nicolai - Josuttis - - - Marshall - Clow - - - - 2001 - 2002 - 2003 - 2004 - Nicolai M. Josuttis - - - - 2012 - Marshall Clow - - - - 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) - - - - STL compliant container wrapper for arrays of constant size - - - - Boost.Array - -
- Introduction - - - - - The C++ Standard Template Library STL as part of the C++ - Standard Library provides a framework for processing algorithms on - different kind of containers. However, ordinary arrays don't - provide the interface of STL containers (although, they provide - the iterator interface of STL containers). - - As replacement for ordinary arrays, the STL provides class - std::vector. However, - std::vector<> provides - the semantics of dynamic arrays. Thus, it manages data to be able - to change the number of elements. This results in some overhead in - case only arrays with static size are needed. - - In his book, Generic Programming and the - STL, Matthew H. Austern introduces a useful wrapper - class for ordinary arrays with static size, called - block. It is safer and has no worse performance than - ordinary arrays. In The C++ Programming - Language, 3rd edition, Bjarne Stroustrup introduces a - similar class, called c_array, which I (Nicolai Josuttis) present - slightly modified in my book The C++ Standard Library - - A Tutorial and Reference, called - carray. This is the essence of these approaches - spiced with many feedback from boost. - - After considering different names, we decided to name this - class simply array. - - Note that this class is suggested to be part of the next - Technical Report, which will extend the C++ Standard (see - http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1548.htm). - - Update: std::array is (as of C++11) part of the C++ standard. - The differences between boost::array and std::array are minimal. - If you are using C++11, you should consider using std::array instead of boost::array. - - - Class array fulfills most - but not all of the requirements of "reversible containers" (see - Section 23.1, [lib.container.requirements] of the C++ - Standard). The reasons array is not an reversible STL container is - because: - - No constructors are provided. - Elements may have an undetermined initial value (see ). - swap() has no constant complexity. - size() is always constant, based on the second template argument of the type. - The container provides no allocator support. - - - - It doesn't fulfill the requirements of a "sequence" (see Section 23.1.1, [lib.sequence.reqmts] of the C++ Standard), except that: - - front() and back() are provided. - operator[] and at() are provided. - - -
- - -
- - - - - STL compliant container wrapper for arrays of constant size - - T - - - T* - - - const T* - - - std::reverse_iterator<iterator> - - - std::reverse_iterator<const_iterator> - - - T& - - - const T& - - - std::size_t - - - std::ptrdiff_t - - - - size_type - N - - - - - - const array<U, N>& - - std::copy(rhs.begin(),rhs.end(), begin()) - - - - - - iterator - - - const_iterator - - - iterator for the first element - will not throw - - - - - iterator - - - const_iterator - - - iterator for position after the last element - will not throw - - - - - const_iterator - - - constant iterator for the first element - will not throw - - - - - const_iterator - - - constant iterator for position after the last element - will not throw - - - - - - - reverse_iterator - - - const_reverse_iterator - - - reverse iterator for the first element of reverse iteration - - - - - reverse_iterator - - - const_reverse_iterator - - - reverse iterator for position after the last element in reverse iteration - - - - - const_reverse_iterator - - - constant reverse iterator for the first element of reverse iteration - will not throw - - - - - const_reverse_iterator - - - constant reverse iterator for position after the last element in reverse iteration - will not throw - - - - - - size_type - N - - - bool - N==0 - will not throw - - - size_type - N - will not throw - - - - - - - reference - - size_type - - - - - const_reference - - size_type - - - - i < N - element with index i - will not throw. - - - - - reference - - size_type - - - - - const_reference - - size_type - - - - element with index i - std::range_error if i >= N - - - - - reference - - - const_reference - - N > 0 - the first element - will not throw - - - - - reference - - - const_reference - - N > 0 - the last element - will not throw - - - - const T* - elems - will not throw - - - - T* - elems - will not throw - - - - - - void - - array<T, N>& - - std::swap_ranges(begin(), end(), other.begin()) - linear in N - - - void - - const T& - - std::fill_n(begin(), N, value) - - - - - T - - - - - - - void - - - array<T, N>& - - - array<T, N>& - - - x.swap(y) - will not throw. - - - - - - - - bool - - - const array<T, N>& - - - const array<T, N>& - - - std::equal(x.begin(), x.end(), y.begin()) - - - - - - - bool - - - const array<T, N>& - - - const array<T, N>& - - - !(x == y) - - - - - - - bool - - - const array<T, N>& - - - const array<T, N>& - - - std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()) - - - - - - - bool - - - const array<T, N>& - - - const array<T, N>& - - - y < x - - - - - - bool - - - const array<T, N>& - - - const array<T, N>& - - - !(y < x) - - - - - - bool - - - const array<T, N>& - - - const array<T, N>& - - - !(x < y) - - - - - - - - T - - - array<T, N>& - - element of array with index Idx - Will static_assert if Idx >= N - - - - - - T - - - const array<T, N>& - - const element of array with index Idx - Will static_assert if Idx >= N - - - - - -
-
- -
- Design Rationale - - There was an important design tradeoff regarding the - constructors: We could implement array as an "aggregate" (see - Section 8.5.1, [dcl.init.aggr], of the C++ Standard). This would - mean: - - An array can be initialized with a - brace-enclosing, comma-separated list of initializers for the - elements of the container, written in increasing subscript - order: - - boost::array<int,4> a = { { 1, 2, 3 } }; - - Note that if there are fewer elements in the - initializer list, then each remaining element gets - default-initialized (thus, it has a defined value). - - - However, this approach has its drawbacks: passing no initializer list means that the elements - have an indetermined initial value, because the rule says - that aggregates may have: - - No user-declared constructors. - No private or protected non-static data members. - No base classes. - No virtual functions. - - - - Nevertheless, The current implementation uses this approach. - - Note that for standard conforming compilers it is possible to - use fewer braces (according to 8.5.1 (11) of the Standard). That is, - you can initialize an array as follows: - - -boost::array<int,4> a = { 1, 2, 3 }; - - - I'd appreciate any constructive feedback. Please note: I don't have time to read all boost - mails. Thus, to make sure that feedback arrives to me, please send - me a copy of each mail regarding this class. - - The code is provided "as is" without expressed or implied - warranty. - -
- -
- For more information... - To find more details about using ordinary arrays in C++ and - the framework of the STL, see e.g. - - The C++ Standard Library - A Tutorial and Reference -by Nicolai M. Josuttis -Addison Wesley Longman, 1999 -ISBN 0-201-37926-0 - - - Home Page of Nicolai - Josuttis -
- -
- Acknowledgements - - Doug Gregor ported the documentation to the BoostBook format. -
- - - -
diff --git a/doc/array/copyright.adoc b/doc/array/copyright.adoc new file mode 100644 index 00000000..f04e3a8f --- /dev/null +++ b/doc/array/copyright.adoc @@ -0,0 +1,15 @@ +//// +Copyright 2024 Christian Mazakas +Distributed under the Boost Software License, Version 1.0. +https://www.boost.org/LICENSE_1_0.txt +//// + +[#copyright] +# Copyright and License +:idprefix: copyright + +Copyright (C) 2001-2004 Nicolai M. Josuttis + +Copyright (C) 2012 Marshall Clow + +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) diff --git a/doc/array/design_rationale.adoc b/doc/array/design_rationale.adoc new file mode 100644 index 00000000..bedc0a07 --- /dev/null +++ b/doc/array/design_rationale.adoc @@ -0,0 +1,43 @@ +//// +Copyright 2001-2004 Nicolai M. Josuttis +Copyright 2012 Marshall Clow +Copyright 2024 Christian Mazakas +Distributed under the Boost Software License, Version 1.0. +https://www.boost.org/LICENSE_1_0.txt +//// + +[#design] +# Design Rationale +:idprefix: design_ +:cpp: C++ + +There was an important design tradeoff regarding the constructors: We could implement array as an "aggregate" (see Section 8.5.1, [dcl.init.aggr], of the C++ Standard). This would mean: + +* An array can be initialized with a brace-enclosing, comma-separated list of initializers for the elements of the container, written in increasing subscript order: ++ +-- +```cpp +boost::array a = { { 1, 2, 3 } }; +``` + +Note that if there are fewer elements in the initializer list, then each remaining element gets default-initialized (thus, it has a defined value). +-- + +However, this approach has its drawbacks: **passing no initializer list means that the elements have an indetermined initial value**, because the rule says that aggregates may have: + +* No user-declared constructors. +* No private or protected non-static data members. +* No base classes. +* No virtual functions. + +Nevertheless, the current implementation uses this approach. + +Note that for standard conforming compilers it is possible to use fewer braces (according to 8.5.1 (11) of the Standard). That is, you can initialize an array as follows: + +```cpp +boost::array a = { 1, 2, 3 }; +``` + +I'd appreciate any constructive feedback. **Please note: I don't have time to read all boost mails. Thus, to make sure that feedback arrives to me, please send me a copy of each mail regarding this class.** + +The code is provided "as is" without expressed or implied warranty. diff --git a/doc/array/information.adoc b/doc/array/information.adoc new file mode 100644 index 00000000..ca8b1a86 --- /dev/null +++ b/doc/array/information.adoc @@ -0,0 +1,22 @@ +//// +Copyright 2001-2004 Nicolai M. Josuttis +Copyright 2012 Marshall Clow +Copyright 2024 Christian Mazakas +Distributed under the Boost Software License, Version 1.0. +https://www.boost.org/LICENSE_1_0.txt +//// + +[#information] +# For more information... +:idprefix: information_ +:cpp: C++ + +To find more details about using ordinary arrays in C++ and the framework of the STL, see e.g. + +The C++ Standard Library - A Tutorial and Reference + +by Nicolai M. Josuttis + +Addison Wesley Longman, 1999 + +ISBN 0-201-37926-0 + + +http://www.josuttis.com/[Home Page of Nicolai Josuttis] diff --git a/doc/array/introduction.adoc b/doc/array/introduction.adoc new file mode 100644 index 00000000..9330a8f9 --- /dev/null +++ b/doc/array/introduction.adoc @@ -0,0 +1,37 @@ +//// +Copyright 2001-2004 Nicolai M. Josuttis +Copyright 2012 Marshall Clow +Copyright 2024 Christian Mazakas +Distributed under the Boost Software License, Version 1.0. +https://www.boost.org/LICENSE_1_0.txt +//// + +[#introduction] +# Introduction +:idprefix: introduction_ +:cpp: C++ + +The {cpp} Standard Template Library STL as part of the {cpp} Standard Library provides a framework for processing algorithms on different kind of containers. However, ordinary arrays don't provide the interface of STL containers (although, they provide the iterator interface of STL containers). + +As replacement for ordinary arrays, the STL provides class `std::vector`. However, `std::vector<>` provides the semantics of dynamic arrays. Thus, it manages data to be able to change the number of elements. This results in some overhead in case only arrays with static size are needed. + +In his book, _Generic Programming and the STL_, Matthew H. Austern introduces a useful wrapper class for ordinary arrays with static size, called `block`. It is safer and has no worse performance than ordinary arrays. In _The {cpp} Programming Language_, 3rd edition, Bjarne Stroustrup introduces a similar class, called c_array, which I (http://www.josuttis.com/[Nicolai Josuttis]) present slightly modified in my book _The {cpp} Standard Library - A Tutorial and Reference_, called `carray`. This is the essence of these approaches spiced with many feedback from https://www.boost.org/[boost]. + +After considering different names, we decided to name this class simply `array`. + +Note that this class is suggested to be part of the next Technical Report, which will extend the {cpp} Standard (see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1548.htm). + +Update: `std::array` is (as of {cpp}11) part of the {cpp} standard. The differences between `boost::array` and `std::array` are minimal. If you are using {cpp}11, you should consider using `std::array` instead of `boost::array`. + +Class `array` fulfills most but not all of the requirements of "reversible containers" (see Section 23.1, [lib.container.requirements] of the {cpp} Standard). The reasons array is not an reversible STL container is because: + +* No constructors are provided. +* Elements may have an undetermined initial value (see the <>). +* `swap()` has no constant complexity. +* `size()` is always constant, based on the second template argument of the type. +* The container provides no allocator support. + +It doesn't fulfill the requirements of a "sequence" (see Section 23.1.1, [lib.sequence.reqmts] of the {cpp} Standard), except that: + +* `front()` and `back()` are provided. +* `operator[]` and `at()` are provided. diff --git a/doc/array/reference.adoc b/doc/array/reference.adoc new file mode 100644 index 00000000..bde92669 --- /dev/null +++ b/doc/array/reference.adoc @@ -0,0 +1,418 @@ +//// +Copyright 2001-2004 Nicolai M. Josuttis +Copyright 2012 Marshall Clow +Copyright 2024 Christian Mazakas +Distributed under the Boost Software License, Version 1.0. +https://www.boost.org/LICENSE_1_0.txt +//// + +[#reference] +# Reference +:idprefix: reference_ +:cpp: C++ + +## Header + +```cpp +namespace boost { + template class array; + template void swap(array&, array&); + template + bool operator==(const array&, const array&); + template + bool operator!=(const array&, const array&); + template + bool operator<(const array&, const array&); + template + bool operator>(const array&, const array&); + template + bool operator<=(const array&, const array&); + template + bool operator>=(const array&, const array&); + template + T boost::get(array&); + template + T boost::get(const array&); +} +``` + +## Class template array + +### Synopsis + +```cpp +// In header: + +template +class array { +public: + // types + typedef T value_type; + typedef T* iterator; + typedef const T* const_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef T& reference; + typedef const T& const_reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + // static constants + static const size_type static_size = N; + + // construct/copy/destruct + template array& operator=(const array&); + + // iterator support + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; + const_iterator cbegin(); + const_iterator cend(); + + // reverse iterator support + reverse_iterator rbegin(); + const_reverse_iterator rbegin() const; + reverse_iterator rend(); + const_reverse_iterator rend() const; + const_reverse_iterator crbegin(); + const_reverse_iterator crend(); + + // capacity + size_type size(); + bool empty(); + size_type max_size(); + + // element access + reference operator[](size_type); + const_reference operator[](size_type) const; + reference at(size_type); + const_reference at(size_type) const; + reference front(); + const_reference front() const; + reference back(); + const_reference back() const; + const T* data() const; + T* c_array(); + + // modifiers + void swap(array&); + void assign(const T&); + + // public data members + T elems[N]; +}; + +// specialized algorithms +template void swap(array&, array&); + +// comparisons +template + bool operator==(const array&, const array&); +template + bool operator!=(const array&, const array&); +template + bool operator<(const array&, const array&); +template + bool operator>(const array&, const array&); +template + bool operator<=(const array&, const array&); +template + bool operator>=(const array&, const array&); + +// specializations +template + T boost::get(array&); +template + T boost::get(const array&); +``` + +### Description + +#### array public construct/copy/destruct + +``` +template array& operator=(const array& other); +``` +[horizontal] +Effects: :: `std::copy(rhs.begin(), rhs.end(), begin())` + +--- + +#### array iterator support + +``` +iterator begin(); +const_iterator begin() const; +``` +[horizontal] +Returns: :: iterator for the first element +Throws: :: will not throw + +--- + +``` +iterator end(); +const_iterator end() const; +``` +[horizontal] +Returns: :: iterator for position after the last element +Throws: :: will not throw + +--- + +``` +const_iterator cbegin(); +``` +[horizontal] +Returns: :: constant iterator for the first element +Throws: :: will not throw + +--- + +``` +const_iterator cend(); +``` +[horizontal] +Returns: :: constant iterator for position after the last element +Throws: :: will not throw + +--- + +#### array reverse iterator support + +``` +reverse_iterator rbegin(); +const_reverse_iterator rbegin() const; +``` +[horizontal] +Returns: :: reverse iterator for the first element of reverse iteration + +--- + +``` +reverse_iterator rend(); +const_reverse_iterator rend() const; +``` +[horizontal] +Returns: :: reverse iterator for position after the last element in reverse iteration + +--- + +``` +const_reverse_iterator crbegin(); +``` +[horizontal] +Returns: :: constant reverse iterator for the first element of reverse iteration +Throws: :: will not throw + +--- + +``` +const_reverse_iterator crend(); +``` +[horizontal] +Returns: :: constant reverse iterator for position after the last element in reverse iteration +Throws: :: will not throw + +--- + +#### array capacity + +``` +size_type size(); +``` +[horizontal] +Returns: :: `N` + +--- + +``` +bool empty(); +``` +[horizontal] +Returns: :: `N==0` +Throws: :: will not throw + +--- + +``` +size_type max_size(); +``` +[horizontal] +Returns: :: `N` +Throws: :: will not throw + +--- + +#### array element access + +``` +reference operator[](size_type i); +const_reference operator[](size_type i) const; +``` +[horizontal] +Requires: :: `i < N` +Returns: :: element with index `i` +Throws: :: will not throw. + +--- + +``` +reference at(size_type i); +const_reference at(size_type i) const; +``` +[horizontal] +Returns: :: element with index `i` +Throws: :: `std::range_error` if `i >= N` + +--- + +``` +reference front(); +const_reference front() const; +``` +[horizontal] +Requires: :: `N > 0` +Returns: :: the first element +Throws: :: will not throw + +--- + +``` +reference back(); +const_reference back() const; +``` +[horizontal] +Requires: :: `N > 0` +Returns: :: the last element +Throws: :: will not throw + +--- + +``` +const T* data() const; +``` +[horizontal] +Returns: :: `elems` +Throws: :: will not throw + +--- + +``` +T* c_array(); +``` +[horizontal] +Returns: :: `elems` +Throws: :: will not throw + +--- + +#### array modifiers + +``` +void swap(array& other); +``` +[horizontal] +Effects: :: `std::swap_ranges(begin(), end(), other.begin())` +Complexity: :: linear in `N` + +--- + +``` +void assign(const T& value); +``` +[horizontal] +Effects: :: `std::fill_n(begin(), N, value)` + +--- + +#### array specialized algorithms + +``` +template void swap(array& x, array& y); +``` +[horizontal] +Effects: :: `x.swap(y)` +Throws: :: will not throw. + +--- + +#### array comparisons + +``` +template + bool operator==(const array& x, const array& y); +``` +[horizontal] +Returns: :: `std::equal(x.begin(), x.end(), y.begin())` + +--- + +``` +template + bool operator!=(const array& x, const array& y); +``` +[horizontal] +Returns: :: `!(x == y)` + +--- + +``` +template + bool operator<(const array& x, const array& y); +``` +[horizontal] +Returns: :: `std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end())` + +--- + +``` +template + bool operator>(const array& x, const array& y); +``` +[horizontal] +Returns: :: `y < x` + +--- + +``` +template + bool operator<=(const array& x, const array& y); +``` +[horizontal] +Returns: :: `!(y < x)` + +--- + +``` +template + bool operator>=(const array& x, const array& y); +``` +[horizontal] +Returns: :: `!(x < y)` + +--- + +#### array specializations + +``` +template + T boost::get(array& arr); +``` +[horizontal] +Returns: :: element of array with index `Idx` +Effects: :: Will `static_assert` if `Idx >= N` + +--- + +``` +template + T boost::get(const array& arr); +``` +[horizontal] +Returns: :: const element of array with index `Idx` +Effects: :: Will `static_assert` if `Idx >= N` + +--- From ea54ab16104beaf491a35b007abfe5a0212ddf16 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 6 Jan 2025 18:45:57 +0200 Subject: [PATCH 056/154] Update index.html --- index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index a9e3c343..cdbc419a 100644 --- a/index.html +++ b/index.html @@ -1,13 +1,13 @@ - + Automatic redirection failed, please go to -../../doc/html/array.html  
+doc/html/array.html  

© Copyright Beman Dawes, 2001

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)

- \ No newline at end of file + From fd24e0592c0389083013d1dab99508e40a1cd0b0 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 9 Jan 2025 20:49:37 +0200 Subject: [PATCH 057/154] Add boostdoc, boostrelease targets to doc/Jamfile.v2 --- doc/Jamfile.v2 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 7087c6c7..83ce1dd2 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -14,3 +14,9 @@ explicit array.pdf ; install pdf_ : array.pdf : pdf ; explicit pdf_ ; + +############################################################################### +alias boostdoc ; +explicit boostdoc ; +alias boostrelease : html_ ; +explicit boostrelease ; From f9bb980a0bdc9a25c5bf630b20e7b5cfe03a023f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 9 Jan 2025 21:01:41 +0200 Subject: [PATCH 058/154] Add array_typedef_test.cpp --- test/Jamfile.v2 | 8 +++++++ test/array_typedef_test.cpp | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 test/array_typedef_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index dde5c33b..11609ab3 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -7,6 +7,8 @@ import testing ; import-search /boost/config/checks ; import config : requires ; +# + run array0.cpp ; run array1.cpp ; run array2.cpp ; @@ -24,4 +26,10 @@ compile-fail array_getfail2.cpp ; run array_hash.cpp : : : [ requires cxx11_noexcept ] ; +# + +run array_typedef_test.cpp ; + +# + run quick.cpp ; diff --git a/test/array_typedef_test.cpp b/test/array_typedef_test.cpp new file mode 100644 index 00000000..d122d1dd --- /dev/null +++ b/test/array_typedef_test.cpp @@ -0,0 +1,43 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +template void test() +{ + typedef boost::array A; + + BOOST_TEST_TRAIT_SAME(typename A::value_type, T); + + BOOST_TEST_TRAIT_SAME(typename A::iterator, T*); + BOOST_TEST_TRAIT_SAME(typename A::const_iterator, T const*); + + BOOST_TEST_TRAIT_SAME(typename A::reverse_iterator, std::reverse_iterator); + BOOST_TEST_TRAIT_SAME(typename A::const_reverse_iterator, std::reverse_iterator); + + BOOST_TEST_TRAIT_SAME(typename A::reference, T&); + BOOST_TEST_TRAIT_SAME(typename A::const_reference, T const&); + + BOOST_TEST_TRAIT_SAME(typename A::size_type, std::size_t); + BOOST_TEST_TRAIT_SAME(typename A::difference_type, std::ptrdiff_t); + + BOOST_TEST_EQ(A::static_size, N); +} + +int main() +{ + test(); + test(); + test(); + + test(); + test(); + test(); + + return boost::report_errors(); +} From e0bd7e85609c6bc422fc3e7883c406758c953860 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 10 Jan 2025 02:57:33 +0200 Subject: [PATCH 059/154] Add array_elems_test.cpp --- test/Jamfile.v2 | 1 + test/array_elems_test.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 test/array_elems_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 11609ab3..91cb6af7 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -29,6 +29,7 @@ run array_hash.cpp # run array_typedef_test.cpp ; +run array_elems_test.cpp ; # diff --git a/test/array_elems_test.cpp b/test/array_elems_test.cpp new file mode 100644 index 00000000..0204c664 --- /dev/null +++ b/test/array_elems_test.cpp @@ -0,0 +1,26 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +template void test() +{ + boost::array a = {}; + + T (&e)[ N ] = a.elems; + + BOOST_TEST_EQ( static_cast( e ), static_cast( &a ) ); +} + +int main() +{ + test(); + test(); + + test(); + test(); + + return boost::report_errors(); +} From 049e98dd57d74127870466702a50b43094af6e36 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 10 Jan 2025 03:30:57 +0200 Subject: [PATCH 060/154] Add array_init_test.cpp --- test/Jamfile.v2 | 1 + test/array_init_test.cpp | 70 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 test/array_init_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 91cb6af7..79d76ce2 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -30,6 +30,7 @@ run array_hash.cpp run array_typedef_test.cpp ; run array_elems_test.cpp ; +run array_init_test.cpp ; # diff --git a/test/array_init_test.cpp b/test/array_init_test.cpp new file mode 100644 index 00000000..faaa7f40 --- /dev/null +++ b/test/array_init_test.cpp @@ -0,0 +1,70 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +template void test1() +{ + boost::array a = {{}}; + + for( std::size_t i = 0; i < N; ++i ) + { + BOOST_TEST_EQ( a[i], T() ); + } +} + +template void test2() +{ + boost::array a = {}; + + for( std::size_t i = 0; i < N; ++i ) + { + BOOST_TEST_EQ( a[i], T() ); + } +} + +template void test3() +{ + boost::array a = {{ 1, 2, 3, 4 }}; + T b[ 4 ] = { 1, 2, 3, 4 }; + + BOOST_TEST_ALL_EQ( a.begin(), a.end(), b + 0, b + 4 ); +} + +template void test4() +{ + boost::array a = { 1, 2, 3, 4 }; + T b[ 4 ] = { 1, 2, 3, 4 }; + + BOOST_TEST_ALL_EQ( a.begin(), a.end(), b + 0, b + 4 ); +} + +int main() +{ + // test1(); + test1(); + test1(); + + // test1(); + test1(); + test1(); + + test2(); + test2(); + test2(); + + // test2(); + test2(); + test2(); + + test3(); + test3(); + + test4(); + test4(); + + return boost::report_errors(); +} From 7fac30e1ab6ab1015cfe4bf0d9ad3bac0375b530 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 10 Jan 2025 03:37:10 +0200 Subject: [PATCH 061/154] Fix msvc-14.0, gcc-4.x failures --- test/array_elems_test.cpp | 3 ++- test/array_init_test.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test/array_elems_test.cpp b/test/array_elems_test.cpp index 0204c664..9506cbfc 100644 --- a/test/array_elems_test.cpp +++ b/test/array_elems_test.cpp @@ -4,10 +4,11 @@ #include #include +#include template void test() { - boost::array a = {}; + boost::array a = {{}}; T (&e)[ N ] = a.elems; diff --git a/test/array_init_test.cpp b/test/array_init_test.cpp index faaa7f40..ae40fd36 100644 --- a/test/array_init_test.cpp +++ b/test/array_init_test.cpp @@ -4,6 +4,8 @@ #include #include +#include +#include #include template void test1() @@ -57,9 +59,18 @@ int main() test2(); // test2(); + +#if BOOST_WORKAROUND(BOOST_MSVC, < 1910) || BOOST_WORKAROUND(BOOST_GCC, < 50000) + + // = {} doesn't work for const T + +#else + test2(); test2(); +#endif + test3(); test3(); From 51fbc208d9d69b56cbe6f5dc77c09f4c579add7e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 10 Jan 2025 03:49:09 +0200 Subject: [PATCH 062/154] Add array_copy_test.cpp --- test/Jamfile.v2 | 1 + test/array_copy_test.cpp | 65 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 test/array_copy_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 79d76ce2..a2add772 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -31,6 +31,7 @@ run array_hash.cpp run array_typedef_test.cpp ; run array_elems_test.cpp ; run array_init_test.cpp ; +run array_copy_test.cpp ; # diff --git a/test/array_copy_test.cpp b/test/array_copy_test.cpp new file mode 100644 index 00000000..bcb29a4b --- /dev/null +++ b/test/array_copy_test.cpp @@ -0,0 +1,65 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +template void test1() +{ + boost::array a1 = {{}}; + boost::array a2 = a1; + + BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() ); +} + +template void test2() +{ + boost::array a1 = {{}}; + + boost::array a2; + a2 = a1; + + BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() ); +} + +template void test3() +{ + boost::array a1 = {{ 1, 2, 3, 4 }}; + boost::array a2 = a1; + + BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() ); +} + +template void test4() +{ + boost::array a1 = { 1, 2, 3, 4 }; + + boost::array a2; + a2 = a1; + + BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() ); +} + +int main() +{ + // test1(); + test1(); + test1(); + + // test1(); + test1(); + test1(); + + // test2(); + test2(); + test2(); + + test3(); + test3(); + + test4(); + + return boost::report_errors(); +} From 72997add9655f77bd5850fa27f44397adbb00442 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 10 Jan 2025 04:07:38 +0200 Subject: [PATCH 063/154] Add array_convert_test.cpp --- test/Jamfile.v2 | 1 + test/array_convert_test.cpp | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 test/array_convert_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index a2add772..64f49d55 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -32,6 +32,7 @@ run array_typedef_test.cpp ; run array_elems_test.cpp ; run array_init_test.cpp ; run array_copy_test.cpp ; +run array_convert_test.cpp ; # diff --git a/test/array_convert_test.cpp b/test/array_convert_test.cpp new file mode 100644 index 00000000..aa1e9c78 --- /dev/null +++ b/test/array_convert_test.cpp @@ -0,0 +1,38 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +template void test2() +{ + boost::array a1 = {}; + + boost::array a2; + a2 = a1; + + BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() ); +} + +template void test4() +{ + boost::array a1 = { 1, 2, 3, 4 }; + + boost::array a2; + a2 = a1; + + BOOST_TEST_ALL_EQ( a1.begin(), a1.end(), a2.begin(), a2.end() ); +} + +int main() +{ + test2(); + test2(); + test2(); + + test4(); + + return boost::report_errors(); +} From 1ae515a17d91603f23114da6142eab0993a63500 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 10 Jan 2025 04:09:16 +0200 Subject: [PATCH 064/154] Update array_copy_test --- test/array_copy_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/array_copy_test.cpp b/test/array_copy_test.cpp index bcb29a4b..e94039a4 100644 --- a/test/array_copy_test.cpp +++ b/test/array_copy_test.cpp @@ -16,7 +16,7 @@ template void test1() template void test2() { - boost::array a1 = {{}}; + boost::array a1 = {}; boost::array a2; a2 = a1; @@ -52,7 +52,7 @@ int main() test1(); test1(); - // test2(); + test2(); test2(); test2(); From c5741a92e72c2f97516baad211da7ec40c1ad6b2 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 10 Jan 2025 04:40:35 +0200 Subject: [PATCH 065/154] Add array_data_test.cpp --- test/Jamfile.v2 | 1 + test/array_data_test.cpp | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 test/array_data_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 64f49d55..fd065c38 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -33,6 +33,7 @@ run array_elems_test.cpp ; run array_init_test.cpp ; run array_copy_test.cpp ; run array_convert_test.cpp ; +run array_data_test.cpp ; # diff --git a/test/array_data_test.cpp b/test/array_data_test.cpp new file mode 100644 index 00000000..d27fec1b --- /dev/null +++ b/test/array_data_test.cpp @@ -0,0 +1,41 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +template void test() +{ + { + boost::array a = {{}}; + + T* p1 = a.data(); + T* p2 = a.elems; + + BOOST_TEST_EQ( p1, p2 ); + } + + { + boost::array const a = {{}}; + + T const* p1 = a.data(); + T const* p2 = a.elems; + + BOOST_TEST_EQ( p1, p2 ); + } +} + +int main() +{ + // test(); + test(); + test(); + + // test(); + test(); + test(); + + return boost::report_errors(); +} From 8999204cae6df8a0791f4896f5035fb23c38a90c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 10 Jan 2025 04:53:08 +0200 Subject: [PATCH 066/154] Add array_iterator_test.cpp --- test/Jamfile.v2 | 1 + test/array_iterator_test.cpp | 108 +++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 test/array_iterator_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index fd065c38..80d89723 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -34,6 +34,7 @@ run array_init_test.cpp ; run array_copy_test.cpp ; run array_convert_test.cpp ; run array_data_test.cpp ; +run array_iterator_test.cpp ; # diff --git a/test/array_iterator_test.cpp b/test/array_iterator_test.cpp new file mode 100644 index 00000000..8b75a07a --- /dev/null +++ b/test/array_iterator_test.cpp @@ -0,0 +1,108 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +template void test() +{ + { + boost::array a = {{}}; + + T* p1 = a.data(); + + { + T* p2 = a.begin(); + T* p3 = a.end(); + + BOOST_TEST_EQ( p2, p1 ); + BOOST_TEST_EQ( p3, p1 + N ); + } + + { + T const* p2 = a.cbegin(); + T const* p3 = a.cend(); + + BOOST_TEST_EQ( p2, p1 ); + BOOST_TEST_EQ( p3, p1 + N ); + } + } + + { + boost::array const a = {{}}; + + T const* p1 = a.data(); + + { + T const* p2 = a.begin(); + T const* p3 = a.end(); + + BOOST_TEST_EQ( p2, p1 ); + BOOST_TEST_EQ( p3, p1 + N ); + } + + { + T const* p2 = a.cbegin(); + T const* p3 = a.cend(); + + BOOST_TEST_EQ( p2, p1 ); + BOOST_TEST_EQ( p3, p1 + N ); + } + } +} + +template void test2() +{ + { + boost::array a = {}; + + { + T* p2 = a.begin(); + T* p3 = a.end(); + + BOOST_TEST_EQ( p2, p3 ); + } + + { + T const* p2 = a.cbegin(); + T const* p3 = a.cend(); + + BOOST_TEST_EQ( p2, p3 ); + } + } + + { + boost::array const a = {}; + + { + T const* p2 = a.begin(); + T const* p3 = a.end(); + + BOOST_TEST_EQ( p2, p3 ); + } + + { + T const* p2 = a.cbegin(); + T const* p3 = a.cend(); + + BOOST_TEST_EQ( p2, p3 ); + } + } +} + +int main() +{ + // test(); + test(); + test(); + + // test(); + test(); + test(); + + test2(); + + return boost::report_errors(); +} From 48b07e63fb963d00191d696ed9a1f4e1f7a931a2 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 10 Jan 2025 05:00:39 +0200 Subject: [PATCH 067/154] Add array_reverse_test.cpp --- test/Jamfile.v2 | 1 + test/array_reverse_test.cpp | 88 +++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 test/array_reverse_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 80d89723..2f18d46b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -35,6 +35,7 @@ run array_copy_test.cpp ; run array_convert_test.cpp ; run array_data_test.cpp ; run array_iterator_test.cpp ; +run array_reverse_test.cpp ; # diff --git a/test/array_reverse_test.cpp b/test/array_reverse_test.cpp new file mode 100644 index 00000000..1d556bda --- /dev/null +++ b/test/array_reverse_test.cpp @@ -0,0 +1,88 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +template void test() +{ + { + boost::array a = {{}}; + + { + std::reverse_iterator r1( a.rbegin() ); + std::reverse_iterator r2( a.end() ); + + BOOST_TEST( r1 == r2 ); + } + + { + std::reverse_iterator r1( a.rend() ); + std::reverse_iterator r2( a.begin() ); + + BOOST_TEST( r1 == r2 ); + } + + { + std::reverse_iterator r1( a.crbegin() ); + std::reverse_iterator r2( a.cend() ); + + BOOST_TEST( r1 == r2 ); + } + + { + std::reverse_iterator r1( a.crend() ); + std::reverse_iterator r2( a.cbegin() ); + + BOOST_TEST( r1 == r2 ); + } + } + + { + boost::array const a = {{}}; + + { + std::reverse_iterator r1( a.rbegin() ); + std::reverse_iterator r2( a.end() ); + + BOOST_TEST( r1 == r2 ); + } + + { + std::reverse_iterator r1( a.rend() ); + std::reverse_iterator r2( a.begin() ); + + BOOST_TEST( r1 == r2 ); + } + + { + std::reverse_iterator r1( a.crbegin() ); + std::reverse_iterator r2( a.cend() ); + + BOOST_TEST( r1 == r2 ); + } + + { + std::reverse_iterator r1( a.crend() ); + std::reverse_iterator r2( a.cbegin() ); + + BOOST_TEST( r1 == r2 ); + } + } +} + +int main() +{ + // test(); + test(); + test(); + + // test(); + test(); + test(); + + return boost::report_errors(); +} From c0488c00a37a2c05b6a4fa98acfb60c5db62508c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 11 Jan 2025 04:13:41 +0200 Subject: [PATCH 068/154] Add array_size_test.cpp --- test/Jamfile.v2 | 1 + test/array_size_test.cpp | 73 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 test/array_size_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 2f18d46b..a3dd7e33 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -36,6 +36,7 @@ run array_convert_test.cpp ; run array_data_test.cpp ; run array_iterator_test.cpp ; run array_reverse_test.cpp ; +run array_size_test.cpp ; # diff --git a/test/array_size_test.cpp b/test/array_size_test.cpp new file mode 100644 index 00000000..8780a08c --- /dev/null +++ b/test/array_size_test.cpp @@ -0,0 +1,73 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +template void test1() +{ + { + boost::array a = {{}}; + + BOOST_TEST_EQ( a.size(), N ); + BOOST_TEST_EQ( a.empty(), N == 0 ); + BOOST_TEST_EQ( a.max_size(), N ); + } + + { + boost::array const a = {{}}; + + BOOST_TEST_EQ( a.size(), N ); + BOOST_TEST_EQ( a.empty(), N == 0 ); + BOOST_TEST_EQ( a.max_size(), N ); + } +} + +template void test2() +{ + typedef boost::array A; + + BOOST_TEST_EQ( A().size(), N ); + BOOST_TEST_EQ( A().empty(), N == 0 ); + BOOST_TEST_EQ( A().max_size(), N ); +} + +// the functions are static, which deviates from the standard +template void test3() +{ + typedef boost::array A; + + BOOST_TEST_EQ( A::size(), N ); + BOOST_TEST_EQ( A::empty(), N == 0 ); + BOOST_TEST_EQ( A::max_size(), N ); + + BOOST_TEST_EQ( A::static_size, N ); +} + +int main() +{ + // test1(); + test1(); + test1(); + + // test1(); + test1(); + test1(); + + test2(); + test2(); + test2(); + + test3(); + test3(); + test3(); + + test3(); + test3(); + test3(); + + return boost::report_errors(); +} From 8d1871b4c299f5075bc37a89be40df6203e9d15b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 11 Jan 2025 04:30:54 +0200 Subject: [PATCH 069/154] Add array_access_test.cpp --- test/Jamfile.v2 | 1 + test/array_access_test.cpp | 117 +++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 test/array_access_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index a3dd7e33..0d629fb9 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -37,6 +37,7 @@ run array_data_test.cpp ; run array_iterator_test.cpp ; run array_reverse_test.cpp ; run array_size_test.cpp ; +run array_access_test.cpp ; # diff --git a/test/array_access_test.cpp b/test/array_access_test.cpp new file mode 100644 index 00000000..44be92e0 --- /dev/null +++ b/test/array_access_test.cpp @@ -0,0 +1,117 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#define BOOST_ENABLE_ASSERT_HANDLER + +#include +#include +#include + +struct assertion_failure +{ +}; + +namespace boost +{ + +void assertion_failed( char const* /*expr*/, char const* /*function*/, char const* /*file*/, long /*line*/ ) +{ + throw assertion_failure(); +} + +void assertion_failed_msg( char const* /*expr*/, char const* /*msg*/, char const* /*function*/, char const* /*file*/, long /*line*/ ) +{ + throw assertion_failure(); +} + +} // namespace boost + +template void test() +{ + { + boost::array a = {{}}; + + T* p1 = a.data(); + + for( std::size_t i = 0; i < N; ++i ) + { + T* p2 = &a[ i ]; + T* p3 = &a.at( i ); + + BOOST_TEST_EQ( p2, p1 + i ); + BOOST_TEST_EQ( p3, p1 + i ); + } + + { + T* p2 = &a.front(); + T* p3 = &a.back(); + + BOOST_TEST_EQ( p2, p1 + 0 ); + BOOST_TEST_EQ( p3, p1 + N - 1 ); + } + + BOOST_TEST_THROWS( a.at( N ), std::out_of_range ); + BOOST_TEST_THROWS( a[ N ], assertion_failure ); + } + + { + boost::array const a = {{}}; + + T const* p1 = a.data(); + + for( std::size_t i = 0; i < N; ++i ) + { + T const* p2 = &a[ i ]; + T const* p3 = &a.at( i ); + + BOOST_TEST_EQ( p2, p1 + i ); + BOOST_TEST_EQ( p3, p1 + i ); + } + + { + T const* p2 = &a.front(); + T const* p3 = &a.back(); + + BOOST_TEST_EQ( p2, p1 + 0 ); + BOOST_TEST_EQ( p3, p1 + N - 1 ); + } + + BOOST_TEST_THROWS( a.at( N ), std::out_of_range ); + BOOST_TEST_THROWS( a[ N ], assertion_failure ); + } +} + +template void test2() +{ + { + boost::array a = {}; + + BOOST_TEST_THROWS( a.at( 0 ), std::out_of_range ); + BOOST_TEST_THROWS( a[ 0 ], std::out_of_range ); + BOOST_TEST_THROWS( a.front(), std::out_of_range ); + BOOST_TEST_THROWS( a.back(), std::out_of_range ); + } + + { + boost::array const a = {}; + + BOOST_TEST_THROWS( a.at( 0 ), std::out_of_range ); + BOOST_TEST_THROWS( a[ 0 ], std::out_of_range ); + BOOST_TEST_THROWS( a.front(), std::out_of_range ); + BOOST_TEST_THROWS( a.back(), std::out_of_range ); + } +} + +int main() +{ + test(); + test(); + + test(); + test(); + + test2(); + + return boost::report_errors(); +} From 63f8f022e229370cefcc3e08d97c3b086502a6ff Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 11 Jan 2025 21:29:33 +0200 Subject: [PATCH 070/154] Add array_c_array_test.cpp --- test/Jamfile.v2 | 1 + test/array_c_array_test.cpp | 70 +++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 test/array_c_array_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 0d629fb9..f4988524 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -38,6 +38,7 @@ run array_iterator_test.cpp ; run array_reverse_test.cpp ; run array_size_test.cpp ; run array_access_test.cpp ; +run array_c_array_test.cpp ; # diff --git a/test/array_c_array_test.cpp b/test/array_c_array_test.cpp new file mode 100644 index 00000000..b65d4449 --- /dev/null +++ b/test/array_c_array_test.cpp @@ -0,0 +1,70 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +// c_array and get_c_array are nonstandard extensions +// probably need to be deprecated and removed + +template void test() +{ + boost::array a = {}; + + T* p1 = a.c_array(); + T* p2 = a.data(); + + BOOST_TEST_EQ( p1, p2 ); +} + +template void test2() +{ + { + boost::array a = {{}}; + + T (&e1)[ N ] = boost::get_c_array( a ); + T (&e2)[ N ] = a.elems; + + BOOST_TEST_EQ( static_cast( e1 ), static_cast( e2 ) ); + } + { + boost::array const a = {{}}; + + T const (&e1)[ N ] = boost::get_c_array( a ); + T const (&e2)[ N ] = a.elems; + + BOOST_TEST_EQ( static_cast( e1 ), static_cast( e2 ) ); + } +} + +int main() +{ + test(); + test(); + test(); + + test(); + +#if BOOST_WORKAROUND(BOOST_MSVC, < 1910) || BOOST_WORKAROUND(BOOST_GCC, < 50000) + + // = {} doesn't work for const T + +#else + + test(); + test(); + +#endif + + test2(); + test2(); + + test2(); + test2(); + + return boost::report_errors(); +} From 4e3d4ef99f4f4a2af3d8718d6d9d9c4affb3b981 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 11 Jan 2025 21:51:06 +0200 Subject: [PATCH 071/154] Add array_fill_test.cpp --- test/Jamfile.v2 | 1 + test/array_fill_test.cpp | 57 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 test/array_fill_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f4988524..21d6cf48 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -39,6 +39,7 @@ run array_reverse_test.cpp ; run array_size_test.cpp ; run array_access_test.cpp ; run array_c_array_test.cpp ; +run array_fill_test.cpp ; # diff --git a/test/array_fill_test.cpp b/test/array_fill_test.cpp new file mode 100644 index 00000000..17ca90fd --- /dev/null +++ b/test/array_fill_test.cpp @@ -0,0 +1,57 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +template void test() +{ + boost::array a = {}; + + a.fill( 1 ); + + for( std::size_t i = 0; i < N; ++i ) + { + BOOST_TEST_EQ( a[i], 1 ); + } +} + +template void test2() +{ + boost::array a = {{ 1, 2, 3, 4 }}; + + a.fill( 5 ); + + for( std::size_t i = 0; i < 4; ++i ) + { + BOOST_TEST_EQ( a[i], 5 ); + } +} + +template void test3() +{ + boost::array a = {{ 1, 2, 3, 4 }}; + + // aliasing + a.fill( a[ 1 ] ); + + for( std::size_t i = 0; i < 4; ++i ) + { + BOOST_TEST_EQ( a[i], 2 ); + } +} + +int main() +{ + test(); + test(); + test(); + + test2(); + + test3(); + + return boost::report_errors(); +} From cbd8e1a8dcf43aeb0294086e2116a9e8d8cacdb3 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 11 Jan 2025 21:56:12 +0200 Subject: [PATCH 072/154] Add array_assign_test.cpp --- test/Jamfile.v2 | 1 + test/array_assign_test.cpp | 60 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 test/array_assign_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 21d6cf48..c7c14bf3 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -40,6 +40,7 @@ run array_size_test.cpp ; run array_access_test.cpp ; run array_c_array_test.cpp ; run array_fill_test.cpp ; +run array_assign_test.cpp ; # diff --git a/test/array_assign_test.cpp b/test/array_assign_test.cpp new file mode 100644 index 00000000..91c9b161 --- /dev/null +++ b/test/array_assign_test.cpp @@ -0,0 +1,60 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +// assign is a nonstandard equivalent of fill +// it probably needs to be deprecated and removed + +template void test() +{ + boost::array a = {}; + + a.assign( 1 ); + + for( std::size_t i = 0; i < N; ++i ) + { + BOOST_TEST_EQ( a[i], 1 ); + } +} + +template void test2() +{ + boost::array a = {{ 1, 2, 3, 4 }}; + + a.assign( 5 ); + + for( std::size_t i = 0; i < 4; ++i ) + { + BOOST_TEST_EQ( a[i], 5 ); + } +} + +template void test3() +{ + boost::array a = {{ 1, 2, 3, 4 }}; + + // aliasing + a.assign( a[ 1 ] ); + + for( std::size_t i = 0; i < 4; ++i ) + { + BOOST_TEST_EQ( a[i], 2 ); + } +} + +int main() +{ + test(); + test(); + test(); + + test2(); + + test3(); + + return boost::report_errors(); +} From c549abb18499bec9634dc913bc8c5d18797ef852 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 11 Jan 2025 22:01:01 +0200 Subject: [PATCH 073/154] Add array_swap_test.cpp --- test/Jamfile.v2 | 1 + test/array_swap_test.cpp | 49 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 test/array_swap_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index c7c14bf3..d32ef700 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -41,6 +41,7 @@ run array_access_test.cpp ; run array_c_array_test.cpp ; run array_fill_test.cpp ; run array_assign_test.cpp ; +run array_swap_test.cpp ; # diff --git a/test/array_swap_test.cpp b/test/array_swap_test.cpp new file mode 100644 index 00000000..fb417980 --- /dev/null +++ b/test/array_swap_test.cpp @@ -0,0 +1,49 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +template void test() +{ + boost::array a1 = {}; + boost::array a2 = {}; + + a1.fill( 1 ); + a2.fill( 2 ); + + a1.swap( a2 ); + + for( std::size_t i = 0; i < N; ++i ) + { + BOOST_TEST_EQ( a1[i], 2 ); + BOOST_TEST_EQ( a2[i], 1 ); + } +} + +template void test2() +{ + boost::array a1 = {{ 1, 2, 3, 4 }}; + boost::array a2 = {{ 5, 6, 7, 8 }}; + + a1.swap( a2 ); + + for( int i = 0; i < 4; ++i ) + { + BOOST_TEST_EQ( a1[i], i+5 ); + BOOST_TEST_EQ( a2[i], i+1 ); + } +} + +int main() +{ + test(); + test(); + test(); + + test2(); + + return boost::report_errors(); +} From 7223d3dfcbbb65cee2f00b565d6ae31847d156e3 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 11 Jan 2025 22:05:37 +0200 Subject: [PATCH 074/154] Add array_swap_test2.cpp --- test/Jamfile.v2 | 1 + test/array_swap_test2.cpp | 49 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 test/array_swap_test2.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d32ef700..64ac0abe 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -42,6 +42,7 @@ run array_c_array_test.cpp ; run array_fill_test.cpp ; run array_assign_test.cpp ; run array_swap_test.cpp ; +run array_swap_test2.cpp ; # diff --git a/test/array_swap_test2.cpp b/test/array_swap_test2.cpp new file mode 100644 index 00000000..6ad173cf --- /dev/null +++ b/test/array_swap_test2.cpp @@ -0,0 +1,49 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +template void test() +{ + boost::array a1 = {}; + boost::array a2 = {}; + + a1.fill( 1 ); + a2.fill( 2 ); + + swap( a1, a2 ); + + for( std::size_t i = 0; i < N; ++i ) + { + BOOST_TEST_EQ( a1[i], 2 ); + BOOST_TEST_EQ( a2[i], 1 ); + } +} + +template void test2() +{ + boost::array a1 = {{ 1, 2, 3, 4 }}; + boost::array a2 = {{ 5, 6, 7, 8 }}; + + swap( a1, a2 ); + + for( int i = 0; i < 4; ++i ) + { + BOOST_TEST_EQ( a1[i], i+5 ); + BOOST_TEST_EQ( a2[i], i+1 ); + } +} + +int main() +{ + test(); + test(); + test(); + + test2(); + + return boost::report_errors(); +} From ff5eb67906503e3b3fa842d74a4d14ec93c697a1 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 12 Jan 2025 02:51:15 +0200 Subject: [PATCH 075/154] Add array_eq_test.cpp --- test/Jamfile.v2 | 1 + test/array_eq_test.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 test/array_eq_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 64ac0abe..8de446d1 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -43,6 +43,7 @@ run array_fill_test.cpp ; run array_assign_test.cpp ; run array_swap_test.cpp ; run array_swap_test2.cpp ; +run array_eq_test.cpp ; # diff --git a/test/array_eq_test.cpp b/test/array_eq_test.cpp new file mode 100644 index 00000000..c0ba3fa4 --- /dev/null +++ b/test/array_eq_test.cpp @@ -0,0 +1,83 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +template void test() +{ + { + boost::array const a1 = {}; + boost::array const a2 = {}; + + BOOST_TEST( a1 == a2 ); + BOOST_TEST_NOT( a1 != a2 ); + } + + for( std::size_t i = 0; i < N; ++i ) + { + boost::array const a1 = {}; + + boost::array a2 = a1; + a2[ i ] = 1; + + BOOST_TEST( a1 != a2 ); + BOOST_TEST_NOT( a1 == a2 ); + + boost::array const a3 = a2; + + BOOST_TEST( a1 != a3 ); + BOOST_TEST_NOT( a1 == a3 ); + } + + { + boost::array a1 = {}; + boost::array a2 = {}; + + a1.fill( 1 ); + a2.fill( 1 ); + + BOOST_TEST( a1 == a2 ); + BOOST_TEST_NOT( a1 != a2 ); + } +} + +template void test2() +{ + { + boost::array const a1 = {{ 1, 2, 3, 4 }}; + boost::array const a2 = {{ 1, 2, 3, 4 }}; + + BOOST_TEST( a1 == a2 ); + BOOST_TEST_NOT( a1 != a2 ); + } + + for( std::size_t i = 0; i < 4; ++i ) + { + boost::array const a1 = {{ 1, 2, 3, 4 }}; + + boost::array a2 = a1; + a2[ i ] = 0; + + BOOST_TEST( a1 != a2 ); + BOOST_TEST_NOT( a1 == a2 ); + + boost::array const a3 = a2; + + BOOST_TEST( a1 != a3 ); + BOOST_TEST_NOT( a1 == a3 ); + } +} + +int main() +{ + test(); + test(); + test(); + + test2(); + + return boost::report_errors(); +} From dca9ae1a60d25d086e3308d53d4ca3361a59a315 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 12 Jan 2025 03:01:00 +0200 Subject: [PATCH 076/154] Add array_lt_test.cpp --- test/Jamfile.v2 | 1 + test/array_lt_test.cpp | 85 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 test/array_lt_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 8de446d1..ae231d40 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -44,6 +44,7 @@ run array_assign_test.cpp ; run array_swap_test.cpp ; run array_swap_test2.cpp ; run array_eq_test.cpp ; +run array_lt_test.cpp ; # diff --git a/test/array_lt_test.cpp b/test/array_lt_test.cpp new file mode 100644 index 00000000..d2ec7f6d --- /dev/null +++ b/test/array_lt_test.cpp @@ -0,0 +1,85 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +template void test() +{ + { + boost::array const a1 = {}; + boost::array const a2 = {}; + + BOOST_TEST_NOT( a1 < a2 ); + BOOST_TEST_NOT( a1 > a2 ); + BOOST_TEST( a1 <= a2 ); + BOOST_TEST( a1 >= a2 ); + } + + { + boost::array a1; + boost::array a2; + + a1.fill( 1 ); + a2.fill( 1 ); + + BOOST_TEST_NOT( a1 < a2 ); + BOOST_TEST_NOT( a1 > a2 ); + BOOST_TEST( a1 <= a2 ); + BOOST_TEST( a1 >= a2 ); + } + + for( std::size_t i = 0; i < N; ++i ) + { + boost::array a1; + boost::array a2; + + a1.fill( 1 ); + a2.fill( 1 ); + + a1[ i ] = 0; + + BOOST_TEST( a1 < a2 ); + BOOST_TEST( a1 <= a2 ); + BOOST_TEST_NOT( a1 > a2 ); + BOOST_TEST_NOT( a1 >= a2 ); + + { + boost::array const a3 = a1; + boost::array const a4 = a2; + + BOOST_TEST( a3 < a4 ); + BOOST_TEST( a3 <= a4 ); + BOOST_TEST_NOT( a3 > a4 ); + BOOST_TEST_NOT( a3 >= a4 ); + } + + a1[ i ] = 2; + + BOOST_TEST( a1 > a2 ); + BOOST_TEST( a1 >= a2 ); + BOOST_TEST_NOT( a1 < a2 ); + BOOST_TEST_NOT( a1 <= a2 ); + + { + boost::array const a3 = a1; + boost::array const a4 = a2; + + BOOST_TEST( a3 > a4 ); + BOOST_TEST( a3 >= a4 ); + BOOST_TEST_NOT( a3 < a4 ); + BOOST_TEST_NOT( a3 <= a4 ); + } + } +} + +int main() +{ + test(); + test(); + test(); + + return boost::report_errors(); +} From 31b9fdd39708feb4e8a8802d7738f16533b7d7a6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 12 Jan 2025 03:20:46 +0200 Subject: [PATCH 077/154] Add array_get_test.cpp --- test/Jamfile.v2 | 1 + test/array_get_test.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 test/array_get_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ae231d40..ef83df74 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -45,6 +45,7 @@ run array_swap_test.cpp ; run array_swap_test2.cpp ; run array_eq_test.cpp ; run array_lt_test.cpp ; +run array_get_test.cpp ; # diff --git a/test/array_get_test.cpp b/test/array_get_test.cpp new file mode 100644 index 00000000..32faa944 --- /dev/null +++ b/test/array_get_test.cpp @@ -0,0 +1,40 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +template void test() +{ + { + boost::array const a = {{ 1, 2, 3, 4 }}; + + BOOST_TEST_EQ( boost::get<0>( a ), 1 ); + BOOST_TEST_EQ( boost::get<1>( a ), 2 ); + BOOST_TEST_EQ( boost::get<2>( a ), 3 ); + BOOST_TEST_EQ( boost::get<3>( a ), 4 ); + } + + { + boost::array a = {{ 1, 2, 3, 4 }}; + + boost::get<0>( a ) += 1; + boost::get<1>( a ) += 2; + boost::get<2>( a ) += 3; + boost::get<3>( a ) += 4; + + BOOST_TEST_EQ( boost::get<0>( a ), 2 ); + BOOST_TEST_EQ( boost::get<1>( a ), 4 ); + BOOST_TEST_EQ( boost::get<2>( a ), 6 ); + BOOST_TEST_EQ( boost::get<3>( a ), 8 ); + } +} + +int main() +{ + test(); + + return boost::report_errors(); +} From 2099995189400d0bff0cb971d234a5a6d9e3e014 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 4 Nov 2024 03:56:02 +0200 Subject: [PATCH 078/154] Uncomment BOOST_CONSTEXPR; update and enable test/array_constexpr.cpp --- include/boost/array.hpp | 8 ++++---- test/Jamfile.v2 | 2 +- test/array_constexpr.cpp | 18 ++++-------------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 02bd76db..21e66328 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -117,14 +117,14 @@ namespace boost { return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; } - /*BOOST_CONSTEXPR*/ const_reference operator[](size_type i) const + BOOST_CONSTEXPR const_reference operator[](size_type i) const { return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; } // at() with range check reference at(size_type i) { return rangecheck(i), elems[i]; } - /*BOOST_CONSTEXPR*/ const_reference at(size_type i) const { return rangecheck(i), elems[i]; } + BOOST_CONSTEXPR const_reference at(size_type i) const { return rangecheck(i), elems[i]; } // front() and back() reference front() @@ -246,14 +246,14 @@ namespace boost { return failed_rangecheck(); } - /*BOOST_CONSTEXPR*/ const_reference operator[](size_type /*i*/) const + BOOST_CONSTEXPR const_reference operator[](size_type /*i*/) const { return failed_rangecheck(); } // at() with range check reference at(size_type /*i*/) { return failed_rangecheck(); } - /*BOOST_CONSTEXPR*/ const_reference at(size_type /*i*/) const { return failed_rangecheck(); } + BOOST_CONSTEXPR const_reference at(size_type /*i*/) const { return failed_rangecheck(); } // front() and back() reference front() diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ef83df74..19f857e3 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -18,7 +18,7 @@ run array5.cpp ; run array6.cpp ; run array7.cpp ; -# run array_constexpr.cpp ; +compile array_constexpr.cpp ; compile-fail array_getfail1.cpp ; compile-fail array_getfail2.cpp ; diff --git a/test/array_constexpr.cpp b/test/array_constexpr.cpp index 48995c9f..a6c0dc6e 100644 --- a/test/array_constexpr.cpp +++ b/test/array_constexpr.cpp @@ -5,27 +5,15 @@ * http://www.boost.org/LICENSE_1_0.txt) */ -#include -#include #include -#include -#ifndef BOOST_NO_CXX11_HDR_ARRAY -#include -#endif +#include #ifndef BOOST_NO_CXX11_CONSTEXPR -constexpr boost::array arr {{ 0,1,2,3,4,5,6,7,8,9 }}; -constexpr std::array arr_std {{ 0,1,2,3,4,5,6,7,8,9 }}; - -template -void sink ( T t ) {} -template -void sink ( boost::array &arr ) {} +constexpr boost::array arr {{ 0,1,2,3,4,5,6,7,8,9 }}; int main() { -// constexpr int two = arr_std.at (2); constexpr int three = arr.at (3); int whatever [ arr.at(4) ]; (void)three; @@ -33,7 +21,9 @@ int main() } #else // no constexpr means no constexpr tests! + int main() { } + #endif From 0da094a21debd96f04f5c502dedad39cb396eec7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 4 Nov 2024 04:06:16 +0200 Subject: [PATCH 079/154] Add BOOST_NOEXCEPT as needed to match std::array --- include/boost/array.hpp | 72 ++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 21e66328..03b22eaf 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -72,13 +72,13 @@ namespace boost { typedef std::ptrdiff_t difference_type; // iterator support - iterator begin() { return elems; } - const_iterator begin() const { return elems; } - const_iterator cbegin() const { return elems; } + iterator begin() BOOST_NOEXCEPT { return elems; } + const_iterator begin() const BOOST_NOEXCEPT { return elems; } + const_iterator cbegin() const BOOST_NOEXCEPT { return elems; } - iterator end() { return elems+N; } - const_iterator end() const { return elems+N; } - const_iterator cend() const { return elems+N; } + iterator end() BOOST_NOEXCEPT { return elems+N; } + const_iterator end() const BOOST_NOEXCEPT { return elems+N; } + const_iterator cend() const BOOST_NOEXCEPT { return elems+N; } // reverse iterator support #if !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) @@ -95,19 +95,19 @@ namespace boost { typedef std::reverse_iterator const_reverse_iterator; #endif - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { + reverse_iterator rbegin() BOOST_NOEXCEPT { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const BOOST_NOEXCEPT { return const_reverse_iterator(end()); } - const_reverse_iterator crbegin() const { + const_reverse_iterator crbegin() const BOOST_NOEXCEPT { return const_reverse_iterator(end()); } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { + reverse_iterator rend() BOOST_NOEXCEPT { return reverse_iterator(begin()); } + const_reverse_iterator rend() const BOOST_NOEXCEPT { return const_reverse_iterator(begin()); } - const_reverse_iterator crend() const { + const_reverse_iterator crend() const BOOST_NOEXCEPT { return const_reverse_iterator(begin()); } @@ -148,9 +148,9 @@ namespace boost { } // size is constant - static BOOST_CONSTEXPR size_type size() { return N; } - static BOOST_CONSTEXPR bool empty() { return false; } - static BOOST_CONSTEXPR size_type max_size() { return N; } + static BOOST_CONSTEXPR size_type size() BOOST_NOEXCEPT { return N; } + static BOOST_CONSTEXPR bool empty() BOOST_NOEXCEPT { return false; } + static BOOST_CONSTEXPR size_type max_size() BOOST_NOEXCEPT { return N; } enum { static_size = N }; // swap (note: linear complexity) @@ -160,11 +160,11 @@ namespace boost { } // direct access to data (read-only) - const T* data() const { return elems; } - T* data() { return elems; } + const T* data() const BOOST_NOEXCEPT { return elems; } + T* data() BOOST_NOEXCEPT { return elems; } // use array as C array (direct read/write access to data) - T* c_array() { return elems; } + T* c_array() BOOST_NOEXCEPT { return elems; } // assignment with type conversion template @@ -201,13 +201,13 @@ namespace boost { typedef std::ptrdiff_t difference_type; // iterator support - iterator begin() { return iterator( reinterpret_cast< T * >( this ) ); } - const_iterator begin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); } - const_iterator cbegin() const { return const_iterator( reinterpret_cast< const T * >( this ) ); } + iterator begin() BOOST_NOEXCEPT { return iterator( reinterpret_cast< T * >( this ) ); } + const_iterator begin() const BOOST_NOEXCEPT { return const_iterator( reinterpret_cast< const T * >( this ) ); } + const_iterator cbegin() const BOOST_NOEXCEPT { return const_iterator( reinterpret_cast< const T * >( this ) ); } - iterator end() { return begin(); } - const_iterator end() const { return begin(); } - const_iterator cend() const { return cbegin(); } + iterator end() BOOST_NOEXCEPT { return begin(); } + const_iterator end() const BOOST_NOEXCEPT { return begin(); } + const_iterator cend() const BOOST_NOEXCEPT { return cbegin(); } // reverse iterator support #if !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) @@ -224,19 +224,19 @@ namespace boost { typedef std::reverse_iterator const_reverse_iterator; #endif - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { + reverse_iterator rbegin() BOOST_NOEXCEPT { return reverse_iterator(end()); } + const_reverse_iterator rbegin() const BOOST_NOEXCEPT { return const_reverse_iterator(end()); } - const_reverse_iterator crbegin() const { + const_reverse_iterator crbegin() const BOOST_NOEXCEPT { return const_reverse_iterator(end()); } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { + reverse_iterator rend() BOOST_NOEXCEPT { return reverse_iterator(begin()); } + const_reverse_iterator rend() const BOOST_NOEXCEPT { return const_reverse_iterator(begin()); } - const_reverse_iterator crend() const { + const_reverse_iterator crend() const BOOST_NOEXCEPT { return const_reverse_iterator(begin()); } @@ -277,20 +277,20 @@ namespace boost { } // size is constant - static BOOST_CONSTEXPR size_type size() { return 0; } - static BOOST_CONSTEXPR bool empty() { return true; } - static BOOST_CONSTEXPR size_type max_size() { return 0; } + static BOOST_CONSTEXPR size_type size() BOOST_NOEXCEPT { return 0; } + static BOOST_CONSTEXPR bool empty() BOOST_NOEXCEPT { return true; } + static BOOST_CONSTEXPR size_type max_size() BOOST_NOEXCEPT { return 0; } enum { static_size = 0 }; void swap (array& /*y*/) { } // direct access to data (read-only) - const T* data() const { return 0; } - T* data() { return 0; } + const T* data() const BOOST_NOEXCEPT { return 0; } + T* data() BOOST_NOEXCEPT { return 0; } // use array as C array (direct read/write access to data) - T* c_array() { return 0; } + T* c_array() BOOST_NOEXCEPT { return 0; } // assignment with type conversion template From 79ca787bfef243432fb377495a5aa7209752c5bd Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 4 Nov 2024 04:29:42 +0200 Subject: [PATCH 080/154] Add more constexpr to match std::array --- include/boost/array.hpp | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 03b22eaf..874d492f 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -72,13 +72,13 @@ namespace boost { typedef std::ptrdiff_t difference_type; // iterator support - iterator begin() BOOST_NOEXCEPT { return elems; } - const_iterator begin() const BOOST_NOEXCEPT { return elems; } - const_iterator cbegin() const BOOST_NOEXCEPT { return elems; } + BOOST_CXX14_CONSTEXPR iterator begin() BOOST_NOEXCEPT { return elems; } + BOOST_CONSTEXPR const_iterator begin() const BOOST_NOEXCEPT { return elems; } + BOOST_CONSTEXPR const_iterator cbegin() const BOOST_NOEXCEPT { return elems; } - iterator end() BOOST_NOEXCEPT { return elems+N; } - const_iterator end() const BOOST_NOEXCEPT { return elems+N; } - const_iterator cend() const BOOST_NOEXCEPT { return elems+N; } + BOOST_CXX14_CONSTEXPR iterator end() BOOST_NOEXCEPT { return elems+N; } + BOOST_CONSTEXPR const_iterator end() const BOOST_NOEXCEPT { return elems+N; } + BOOST_CONSTEXPR const_iterator cend() const BOOST_NOEXCEPT { return elems+N; } // reverse iterator support #if !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) @@ -112,7 +112,7 @@ namespace boost { } // operator[] - reference operator[](size_type i) + BOOST_CXX14_CONSTEXPR reference operator[](size_type i) { return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; } @@ -123,11 +123,11 @@ namespace boost { } // at() with range check - reference at(size_type i) { return rangecheck(i), elems[i]; } + BOOST_CXX14_CONSTEXPR reference at(size_type i) { return rangecheck(i), elems[i]; } BOOST_CONSTEXPR const_reference at(size_type i) const { return rangecheck(i), elems[i]; } // front() and back() - reference front() + BOOST_CXX14_CONSTEXPR reference front() { return elems[0]; } @@ -137,7 +137,7 @@ namespace boost { return elems[0]; } - reference back() + BOOST_CXX14_CONSTEXPR reference back() { return elems[N-1]; } @@ -154,14 +154,14 @@ namespace boost { enum { static_size = N }; // swap (note: linear complexity) - void swap (array& y) { + BOOST_CXX14_CONSTEXPR void swap (array& y) { for (size_type i = 0; i < N; ++i) boost::core::invoke_swap(elems[i],y.elems[i]); } // direct access to data (read-only) - const T* data() const BOOST_NOEXCEPT { return elems; } - T* data() BOOST_NOEXCEPT { return elems; } + BOOST_CONSTEXPR const T* data() const BOOST_NOEXCEPT { return elems; } + BOOST_CXX14_CONSTEXPR T* data() BOOST_NOEXCEPT { return elems; } // use array as C array (direct read/write access to data) T* c_array() BOOST_NOEXCEPT { return elems; } @@ -175,7 +175,7 @@ namespace boost { // assign one value to all elements void assign (const T& value) { fill ( value ); } // A synonym for fill - void fill (const T& value) + BOOST_CXX14_CONSTEXPR void fill (const T& value) { std::fill_n(begin(),size(),value); } @@ -286,8 +286,8 @@ namespace boost { } // direct access to data (read-only) - const T* data() const BOOST_NOEXCEPT { return 0; } - T* data() BOOST_NOEXCEPT { return 0; } + BOOST_CONSTEXPR const T* data() const BOOST_NOEXCEPT { return 0; } + BOOST_CXX14_CONSTEXPR T* data() BOOST_NOEXCEPT { return 0; } // use array as C array (direct read/write access to data) T* c_array() BOOST_NOEXCEPT { return 0; } @@ -300,7 +300,7 @@ namespace boost { // assign one value to all elements void assign (const T& value) { fill ( value ); } - void fill (const T& ) {} + BOOST_CXX14_CONSTEXPR void fill (const T& ) {} // check range (may be private because it is static) static reference failed_rangecheck () { @@ -320,27 +320,27 @@ namespace boost { // comparisons template - bool operator== (const array& x, const array& y) { + BOOST_CXX14_CONSTEXPR bool operator== (const array& x, const array& y) { return std::equal(x.begin(), x.end(), y.begin()); } template - bool operator< (const array& x, const array& y) { + BOOST_CXX14_CONSTEXPR bool operator< (const array& x, const array& y) { return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); } template - bool operator!= (const array& x, const array& y) { + BOOST_CXX14_CONSTEXPR bool operator!= (const array& x, const array& y) { return !(x==y); } template - bool operator> (const array& x, const array& y) { + BOOST_CXX14_CONSTEXPR bool operator> (const array& x, const array& y) { return y - bool operator<= (const array& x, const array& y) { + BOOST_CXX14_CONSTEXPR bool operator<= (const array& x, const array& y) { return !(y - bool operator>= (const array& x, const array& y) { + BOOST_CXX14_CONSTEXPR bool operator>= (const array& x, const array& y) { return !(x Date: Mon, 4 Nov 2024 12:59:39 +0200 Subject: [PATCH 081/154] Work around GCC 4.x constexpr failure in operator[] --- include/boost/array.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 874d492f..4c5c82c0 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -31,7 +31,8 @@ #ifndef BOOST_ARRAY_HPP #define BOOST_ARRAY_HPP -#include +#include +#include #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) # pragma warning(push) @@ -50,9 +51,6 @@ #include #include -// FIXES for broken compilers -#include - namespace boost { @@ -117,7 +115,10 @@ namespace boost { return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; } - BOOST_CONSTEXPR const_reference operator[](size_type i) const +#if !BOOST_WORKAROUND(BOOST_GCC, < 50000) + BOOST_CONSTEXPR +#endif + const_reference operator[](size_type i) const { return BOOST_ASSERT_MSG( i < N, "out of range" ), elems[i]; } From 8c5f36ae5237fcd4da8005d986e5e15201d91f0d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 15 Jan 2025 20:18:14 +0200 Subject: [PATCH 082/154] array access operations are never constexpr --- include/boost/array.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 4c5c82c0..2ecd800e 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -247,14 +247,14 @@ namespace boost { return failed_rangecheck(); } - BOOST_CONSTEXPR const_reference operator[](size_type /*i*/) const + const_reference operator[](size_type /*i*/) const { return failed_rangecheck(); } // at() with range check - reference at(size_type /*i*/) { return failed_rangecheck(); } - BOOST_CONSTEXPR const_reference at(size_type /*i*/) const { return failed_rangecheck(); } + reference at(size_type /*i*/) { return failed_rangecheck(); } + const_reference at(size_type /*i*/) const { return failed_rangecheck(); } // front() and back() reference front() @@ -262,7 +262,7 @@ namespace boost { return failed_rangecheck(); } - BOOST_CONSTEXPR const_reference front() const + const_reference front() const { return failed_rangecheck(); } @@ -272,7 +272,7 @@ namespace boost { return failed_rangecheck(); } - BOOST_CONSTEXPR const_reference back() const + const_reference back() const { return failed_rangecheck(); } From 536412674f38bb97de3b34a33fe1641d84776dbb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 15 Jan 2025 20:52:27 +0200 Subject: [PATCH 083/154] Add Drone support --- .drone.jsonnet | 354 ++++++++++++++++++++++++++++++++ .drone.star | 37 ---- .drone/96ad197d74-2319b6d45f.sh | 37 ---- .drone/after-success.sh | 3 - .drone/before-install.sh | 3 - .drone/before-script.sh | 3 - .drone/boost.sh | 41 ---- .drone/drone.bat | 23 +++ .drone/drone.sh | 25 +++ 9 files changed, 402 insertions(+), 124 deletions(-) create mode 100644 .drone.jsonnet delete mode 100644 .drone.star delete mode 100755 .drone/96ad197d74-2319b6d45f.sh delete mode 100755 .drone/after-success.sh delete mode 100755 .drone/before-install.sh delete mode 100755 .drone/before-script.sh delete mode 100755 .drone/boost.sh create mode 100644 .drone/drone.bat create mode 100755 .drone/drone.sh diff --git a/.drone.jsonnet b/.drone.jsonnet new file mode 100644 index 00000000..02534867 --- /dev/null +++ b/.drone.jsonnet @@ -0,0 +1,354 @@ +# Copyright 2022 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +local library = "array"; + +local triggers = +{ + branch: [ "master", "develop", "feature/*" ] +}; + +local ubsan = { UBSAN: '1', UBSAN_OPTIONS: 'print_stacktrace=1' }; +local asan = { ASAN: '1' }; + +local linux_pipeline(name, image, environment, packages = "", sources = [], arch = "amd64") = +{ + name: name, + kind: "pipeline", + type: "docker", + trigger: triggers, + platform: + { + os: "linux", + arch: arch + }, + steps: + [ + { + name: "everything", + image: image, + environment: environment, + commands: + [ + 'set -e', + 'uname -a', + 'echo $DRONE_STAGE_MACHINE', + 'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -', + ] + + (if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) + + (if packages != "" then [ 'apt-get update', 'apt-get -y install ' + packages ] else []) + + [ + 'export LIBRARY=' + library, + './.drone/drone.sh', + ] + } + ] +}; + +local macos_pipeline(name, environment, xcode_version = "12.2", osx_version = "catalina", arch = "amd64") = +{ + name: name, + kind: "pipeline", + type: "exec", + trigger: triggers, + platform: { + "os": "darwin", + "arch": arch + }, + node: { + "os": osx_version + }, + steps: [ + { + name: "everything", + environment: environment + { "DEVELOPER_DIR": "/Applications/Xcode-" + xcode_version + ".app/Contents/Developer" }, + commands: + [ + 'export LIBRARY=' + library, + './.drone/drone.sh', + ] + } + ] +}; + +local windows_pipeline(name, image, environment, arch = "amd64") = +{ + name: name, + kind: "pipeline", + type: "docker", + trigger: triggers, + platform: + { + os: "windows", + arch: arch + }, + "steps": + [ + { + name: "everything", + image: image, + environment: environment, + commands: + [ + 'cmd /C .drone\\\\drone.bat ' + library, + ] + } + ] +}; + +[ + linux_pipeline( + "Linux 16.04 GCC 4.4", + "cppalliance/droneubuntu1604:1", + { TOOLSET: 'gcc', COMPILER: 'g++-4.4', CXXSTD: '98' }, + "g++-4.4", + [ "ppa:ubuntu-toolchain-r/test" ], + ), + + linux_pipeline( + "Linux 16.04 GCC 4.6", + "cppalliance/droneubuntu1604:1", + { TOOLSET: 'gcc', COMPILER: 'g++-4.6', CXXSTD: '98' }, + "g++-4.6", + [ "ppa:ubuntu-toolchain-r/test" ], + ), + + linux_pipeline( + "Linux 16.04 GCC 4.7", + "cppalliance/droneubuntu1604:1", + { TOOLSET: 'gcc', COMPILER: 'g++-4.7', CXXSTD: '98' }, + "g++-4.7", + ), + + linux_pipeline( + "Linux 16.04 GCC 4.8", + "cppalliance/droneubuntu1604:1", + { TOOLSET: 'gcc', COMPILER: 'g++-4.8', CXXSTD: '03,11' }, + "g++-4.8", + ), + + linux_pipeline( + "Linux 16.04 GCC 4.9", + "cppalliance/droneubuntu1604:1", + { TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11' }, + "g++-4.9", + ), + + linux_pipeline( + "Linux 16.04 GCC 5*", + "cppalliance/droneubuntu1604:1", + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14' }, + ), + + linux_pipeline( + "Linux 18.04 GCC 6", + "cppalliance/droneubuntu1804:1", + { TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '03,11,14' }, + "g++-6", + ), + + linux_pipeline( + "Linux 18.04 GCC 7* 32/64", + "cppalliance/droneubuntu1804:1", + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17', ADDRMD: '32,64' }, + ), + + linux_pipeline( + "Linux 18.04 GCC 8", + "cppalliance/droneubuntu1804:1", + { TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '03,11,14,17' }, + "g++-8", + ), + + linux_pipeline( + "Linux 20.04 GCC 9* 32/64", + "cppalliance/droneubuntu2004:1", + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' }, + ), + + linux_pipeline( + "Linux 20.04 GCC 9* ARM64", + "cppalliance/droneubuntu2004:multiarch", + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' }, + arch="arm64", + ), + + linux_pipeline( + "Linux 20.04 GCC 9* S390x", + "cppalliance/droneubuntu2004:multiarch", + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' }, + arch="s390x", + ), + + linux_pipeline( + "Linux 20.04 GCC 10 32/64", + "cppalliance/droneubuntu2004:1", + { TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '32,64' }, + "g++-10-multilib", + ), + + linux_pipeline( + "Linux 22.04 GCC 11* 32/64", + "cppalliance/droneubuntu2204:1", + { TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' }, + ), + + linux_pipeline( + "Linux 22.04 GCC 12 32/64", + "cppalliance/droneubuntu2204:1", + { TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' }, + "g++-12-multilib", + ), + + linux_pipeline( + "Linux 24.04 GCC 13 32/64 UBSAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' } + ubsan, + "g++-13-multilib", + ), + + linux_pipeline( + "Linux 24.04 GCC 14 32/64 ASAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32,64' } + asan, + "g++-14-multilib", + ), + + linux_pipeline( + "Linux 16.04 Clang 3.5", + "cppalliance/droneubuntu1604:1", + { TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '03,11' }, + "clang-3.5", + ), + + linux_pipeline( + "Linux 16.04 Clang 3.6", + "cppalliance/droneubuntu1604:1", + { TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '03,11,14' }, + "clang-3.6", + ), + + linux_pipeline( + "Linux 16.04 Clang 3.7", + "cppalliance/droneubuntu1604:1", + { TOOLSET: 'clang', COMPILER: 'clang++-3.7', CXXSTD: '03,11,14' }, + "clang-3.7", + ), + + linux_pipeline( + "Linux 16.04 Clang 3.8", + "cppalliance/droneubuntu1604:1", + { TOOLSET: 'clang', COMPILER: 'clang++-3.8', CXXSTD: '03,11,14' }, + "clang-3.8", + ), + + linux_pipeline( + "Linux 22.04 Clang 13", + "cppalliance/droneubuntu2204:1", + { TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '03,11,14,17,20' }, + "clang-13", + ), + + linux_pipeline( + "Linux 22.04 Clang 14", + "cppalliance/droneubuntu2204:1", + { TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20' }, + "clang-14", + ), + + linux_pipeline( + "Linux 22.04 Clang 15", + "cppalliance/droneubuntu2204:1", + { TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' }, + "clang-15", + ), + + linux_pipeline( + "Linux 24.04 Clang 16", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '03,11,14,17,20,2b' }, + "clang-16", + ), + + linux_pipeline( + "Linux 24.04 Clang 17 UBSAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + ubsan, + "clang-17", + ), + + linux_pipeline( + "Linux 24.04 Clang 17 ASAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + asan, + "clang-17", + ), + + linux_pipeline( + "Linux 24.04 Clang 18 UBSAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' } + ubsan, + "clang-18", + ), + + linux_pipeline( + "Linux 24.04 Clang 18 ASAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' } + asan, + "clang-18", + ), + + linux_pipeline( + "Linux 24.10 Clang 19", + "cppalliance/droneubuntu2410:1", + { TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '03,11,14,17,20,2b' }, + "clang-19", + ), + + macos_pipeline( + "MacOS 10.15 Xcode 12.2 UBSAN", + { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + ubsan, + ), + + macos_pipeline( + "MacOS 10.15 Xcode 12.2 ASAN", + { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + asan, + ), + + macos_pipeline( + "MacOS 12.4 Xcode 13.4.1 UBSAN", + { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + ubsan, + xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64", + ), + + macos_pipeline( + "MacOS 12.4 Xcode 13.4.1 ASAN", + { TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + asan, + xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64", + ), + + windows_pipeline( + "Windows VS2015 msvc-14.0", + "cppalliance/dronevs2015", + { TOOLSET: 'msvc-14.0', CXXSTD: '14,latest', B2_DONT_EMBED_MANIFEST: '1' }, + ), + + windows_pipeline( + "Windows VS2017 msvc-14.1", + "cppalliance/dronevs2017", + { TOOLSET: 'msvc-14.1', CXXSTD: '14,17,latest' }, + ), + + windows_pipeline( + "Windows VS2019 msvc-14.2", + "cppalliance/dronevs2019", + { TOOLSET: 'msvc-14.2', CXXSTD: '14,17,20,latest' }, + ), + + windows_pipeline( + "Windows VS2022 msvc-14.3", + "cppalliance/dronevs2022:1", + { TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' }, + ), +] diff --git a/.drone.star b/.drone.star deleted file mode 100644 index 477c6c5c..00000000 --- a/.drone.star +++ /dev/null @@ -1,37 +0,0 @@ -# Use, modification, and distribution are -# subject to the Boost Software License, Version 1.0. (See accompanying -# file LICENSE.txt) -# -# Copyright Rene Rivera 2020. - -# For Drone CI we use the Starlark scripting language to reduce duplication. -# As the yaml syntax for Drone CI is rather limited. -# -# -globalenv={} -linuxglobalimage="cppalliance/droneubuntu1604:1" -windowsglobalimage="cppalliance/dronevs2019" - -def main(ctx): - return [ - linux_cxx("TEST_CMAKE=TRUE Job 0", "g++", packages="", buildtype="96ad197d74-2319b6d45f", image=linuxglobalimage, environment={'TEST_CMAKE': 'TRUE', 'DRONE_JOB_UUID': 'b6589fc6ab'}, globalenv=globalenv), - linux_cxx("TOOLSET=gcc COMPILER=g++ CXXSTD=03,11 Job 1", "g++", packages="", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '356a192b79'}, globalenv=globalenv), - linux_cxx("TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11 Job 2", "g++-4.7", packages="g++-4.7", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.7', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'da4b9237ba'}, globalenv=globalenv), - linux_cxx("TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11 Job 3", "g++-4.8", packages="g++-4.8", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.8', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '77de68daec'}, globalenv=globalenv), - linux_cxx("TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11 Job 4", "g++-4.9", packages="g++-4.9", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-4.9', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': '1b64538924'}, globalenv=globalenv), - linux_cxx("TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z Job 5", "g++-5", packages="g++-5", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-5', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'ac3478d69a'}, globalenv=globalenv), - linux_cxx("TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z Job 6", "g++-6", packages="g++-6", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-6', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'c1dfd96eea'}, globalenv=globalenv), - linux_cxx("TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 Job 7", "g++-7", packages="g++-7", buildtype="boost", image="cppalliance/droneubuntu1404:1", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-7', 'CXXSTD': '03,11,14,17', 'DRONE_JOB_UUID': '902ba3cda1'}, globalenv=globalenv), - linux_cxx("TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 Job 8", "clang++", packages="", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '03,11', 'DRONE_JOB_UUID': 'fe5dbbcea5'}, globalenv=globalenv), - linux_cxx("TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03, Job 9", "clang++", packages="clang-3.5 libstdc++-4.9-dev", llvm_os="precise", llvm_ver="3.5", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.5', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '0ade7c2cf9'}, globalenv=globalenv), - linux_cxx("TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03, Job 10", "clang++", packages="clang-3.6", llvm_os="precise", llvm_ver="3.6", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.6', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'b1d5781111'}, globalenv=globalenv), - linux_cxx("TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03, Job 11", "clang++", packages="clang-3.7", llvm_os="precise", llvm_ver="3.7", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.7', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '17ba079149'}, globalenv=globalenv), - linux_cxx("TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03, Job 12", "clang++-3.8", packages="clang-3.8 libstdc++-4.9-dev", llvm_os="precise", llvm_ver="3.8", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.8', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '7b52009b64'}, globalenv=globalenv), - linux_cxx("TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03, Job 13", "clang++-3.9", packages="clang-3.9 libstdc++-4.9-dev", llvm_os="precise", llvm_ver="3.9", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-3.9', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'bd307a3ec3'}, globalenv=globalenv), - linux_cxx("TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03, Job 14", "clang++-4.0", packages="clang-4.0", llvm_os="xenial", llvm_ver="4.0", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-4.0', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'fa35e19212'}, globalenv=globalenv), - linux_cxx("TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03, Job 15", "clang++-5.0", packages="clang-5.0", llvm_os="xenial", llvm_ver="5.0", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-5.0', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': 'f1abd67035'}, globalenv=globalenv), - osx_cxx("TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,1 Job 16", "clang++", packages="", buildtype="boost", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '03,11,14,1z', 'DRONE_JOB_UUID': '1574bddb75'}, globalenv=globalenv), - ] - -# from https://github.com/boostorg/boost-ci -load("@boost_ci//ci/drone/:functions.star", "linux_cxx","windows_cxx","osx_cxx","freebsd_cxx") diff --git a/.drone/96ad197d74-2319b6d45f.sh b/.drone/96ad197d74-2319b6d45f.sh deleted file mode 100755 index bdc59171..00000000 --- a/.drone/96ad197d74-2319b6d45f.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -set -ex -export TRAVIS_BUILD_DIR=$(pwd) -export DRONE_BUILD_DIR=$(pwd) -export TRAVIS_BRANCH=$DRONE_BRANCH -export VCS_COMMIT_ID=$DRONE_COMMIT -export GIT_COMMIT=$DRONE_COMMIT -export REPO_NAME=$DRONE_REPO -export PATH=~/.local/bin:/usr/local/bin:$PATH - -echo '==================================> BEFORE_INSTALL' - -. .drone/before-install.sh - -echo '==================================> INSTALL' - -BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true -git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/assert.git ../assert -git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/config.git ../config -git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/core.git ../core -git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/static_assert.git ../static_assert -git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/throw_exception.git ../throw_exception - -echo '==================================> BEFORE_SCRIPT' - -. $DRONE_BUILD_DIR/.drone/before-script.sh - -echo '==================================> SCRIPT' - -mkdir __build__ && cd __build__ -cmake ../test/test_cmake -cmake --build . - -echo '==================================> AFTER_SUCCESS' - -. $DRONE_BUILD_DIR/.drone/after-success.sh diff --git a/.drone/after-success.sh b/.drone/after-success.sh deleted file mode 100755 index 7a693aac..00000000 --- a/.drone/after-success.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - - diff --git a/.drone/before-install.sh b/.drone/before-install.sh deleted file mode 100755 index 7a693aac..00000000 --- a/.drone/before-install.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - - diff --git a/.drone/before-script.sh b/.drone/before-script.sh deleted file mode 100755 index 7a693aac..00000000 --- a/.drone/before-script.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - - diff --git a/.drone/boost.sh b/.drone/boost.sh deleted file mode 100755 index 144ed057..00000000 --- a/.drone/boost.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -set -ex -export TRAVIS_BUILD_DIR=$(pwd) -export DRONE_BUILD_DIR=$(pwd) -export TRAVIS_BRANCH=$DRONE_BRANCH -export VCS_COMMIT_ID=$DRONE_COMMIT -export GIT_COMMIT=$DRONE_COMMIT -export REPO_NAME=$DRONE_REPO -export PATH=~/.local/bin:/usr/local/bin:$PATH - -echo '==================================> BEFORE_INSTALL' - -. .drone/before-install.sh - -echo '==================================> INSTALL' - -BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true -cd .. -git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root -cd boost-root -git submodule update --init tools/build -git submodule update --init libs/config -git submodule update --init tools/boostdep -cp -r $TRAVIS_BUILD_DIR/* libs/array -python tools/boostdep/depinst/depinst.py array -./bootstrap.sh -./b2 headers - -echo '==================================> BEFORE_SCRIPT' - -. $DRONE_BUILD_DIR/.drone/before-script.sh - -echo '==================================> SCRIPT' - -echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam -./b2 -j 3 libs/array/test toolset=$TOOLSET cxxstd=$CXXSTD - -echo '==================================> AFTER_SUCCESS' - -. $DRONE_BUILD_DIR/.drone/after-success.sh diff --git a/.drone/drone.bat b/.drone/drone.bat new file mode 100644 index 00000000..66aaf78d --- /dev/null +++ b/.drone/drone.bat @@ -0,0 +1,23 @@ +@REM Copyright 2022 Peter Dimov +@REM Distributed under the Boost Software License, Version 1.0. +@REM https://www.boost.org/LICENSE_1_0.txt + +@ECHO ON + +set LIBRARY=%1 +set DRONE_BUILD_DIR=%CD% + +set BOOST_BRANCH=develop +if "%DRONE_BRANCH%" == "master" set BOOST_BRANCH=master +cd .. +git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root +cd boost-root +git submodule update --init tools/boostdep +xcopy /s /e /q %DRONE_BUILD_DIR% libs\%LIBRARY%\ +python tools/boostdep/depinst/depinst.py %LIBRARY% +cmd /c bootstrap +b2 -d0 headers + +if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD% +if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD% +b2 -j3 libs/%LIBRARY%/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker diff --git a/.drone/drone.sh b/.drone/drone.sh new file mode 100755 index 00000000..2f2125df --- /dev/null +++ b/.drone/drone.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Copyright 2022 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +set -ex +export PATH=~/.local/bin:/usr/local/bin:$PATH + +DRONE_BUILD_DIR=$(pwd) + +BOOST_BRANCH=develop +if [ "$DRONE_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi + +cd .. +git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root +cd boost-root +git submodule update --init tools/boostdep +cp -r $DRONE_BUILD_DIR/* libs/$LIBRARY +python tools/boostdep/depinst/depinst.py $LIBRARY +./bootstrap.sh +./b2 -d0 headers + +echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam +./b2 -j3 libs/$LIBRARY/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+undefined-sanitizer=norecover debug-symbols=on} ${ASAN:+address-sanitizer=norecover debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS} From 01983ff60439e0e0b1defdab3ca6c068be513472 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 15 Jan 2025 21:12:57 +0200 Subject: [PATCH 084/154] Remove GCC 4.4 from Drone --- .drone.jsonnet | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 02534867..8c214e88 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -98,14 +98,6 @@ local windows_pipeline(name, image, environment, arch = "amd64") = }; [ - linux_pipeline( - "Linux 16.04 GCC 4.4", - "cppalliance/droneubuntu1604:1", - { TOOLSET: 'gcc', COMPILER: 'g++-4.4', CXXSTD: '98' }, - "g++-4.4", - [ "ppa:ubuntu-toolchain-r/test" ], - ), - linux_pipeline( "Linux 16.04 GCC 4.6", "cppalliance/droneubuntu1604:1", From 9b8a342f44268404a5c7a0b0308d56746e3c7fc2 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 18:00:27 +0200 Subject: [PATCH 085/154] Update documentation --- doc/array.adoc | 3 +- doc/array/copyright.adoc | 2 +- doc/array/design_rationale.adoc | 4 - doc/array/introduction.adoc | 17 +- doc/array/reference.adoc | 327 +++++++++++++++----------------- 5 files changed, 171 insertions(+), 182 deletions(-) diff --git a/doc/array.adoc b/doc/array.adoc index d6292b50..66a90baf 100644 --- a/doc/array.adoc +++ b/doc/array.adoc @@ -6,7 +6,7 @@ Distributed under the Boost Software License, Version 1.0. https://www.boost.org/LICENSE_1_0.txt //// -# Array +# Boost.Array Nicolai M. Josuttis :toc: left :toclevels: 4 @@ -18,7 +18,6 @@ Nicolai M. Josuttis :leveloffset: +1 - include::array/introduction.adoc[] include::array/reference.adoc[] include::array/design_rationale.adoc[] diff --git a/doc/array/copyright.adoc b/doc/array/copyright.adoc index f04e3a8f..ca1724cb 100644 --- a/doc/array/copyright.adoc +++ b/doc/array/copyright.adoc @@ -12,4 +12,4 @@ Copyright (C) 2001-2004 Nicolai M. Josuttis Copyright (C) 2012 Marshall Clow -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) +Distributed under the https://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0]. diff --git a/doc/array/design_rationale.adoc b/doc/array/design_rationale.adoc index bedc0a07..7a32d28b 100644 --- a/doc/array/design_rationale.adoc +++ b/doc/array/design_rationale.adoc @@ -37,7 +37,3 @@ Note that for standard conforming compilers it is possible to use fewer braces ( ```cpp boost::array a = { 1, 2, 3 }; ``` - -I'd appreciate any constructive feedback. **Please note: I don't have time to read all boost mails. Thus, to make sure that feedback arrives to me, please send me a copy of each mail regarding this class.** - -The code is provided "as is" without expressed or implied warranty. diff --git a/doc/array/introduction.adoc b/doc/array/introduction.adoc index 9330a8f9..a334f0a2 100644 --- a/doc/array/introduction.adoc +++ b/doc/array/introduction.adoc @@ -11,11 +11,18 @@ https://www.boost.org/LICENSE_1_0.txt :idprefix: introduction_ :cpp: C++ -The {cpp} Standard Template Library STL as part of the {cpp} Standard Library provides a framework for processing algorithms on different kind of containers. However, ordinary arrays don't provide the interface of STL containers (although, they provide the iterator interface of STL containers). - -As replacement for ordinary arrays, the STL provides class `std::vector`. However, `std::vector<>` provides the semantics of dynamic arrays. Thus, it manages data to be able to change the number of elements. This results in some overhead in case only arrays with static size are needed. - -In his book, _Generic Programming and the STL_, Matthew H. Austern introduces a useful wrapper class for ordinary arrays with static size, called `block`. It is safer and has no worse performance than ordinary arrays. In _The {cpp} Programming Language_, 3rd edition, Bjarne Stroustrup introduces a similar class, called c_array, which I (http://www.josuttis.com/[Nicolai Josuttis]) present slightly modified in my book _The {cpp} Standard Library - A Tutorial and Reference_, called `carray`. This is the essence of these approaches spiced with many feedback from https://www.boost.org/[boost]. +The {cpp} Standard Template Library STL as part of the {cpp} Standard Library provides a framework for processing algorithms on different kind of containers. +However, ordinary arrays don't provide the interface of STL containers (although, they provide the iterator interface of STL containers). + +As replacement for ordinary arrays, the STL provides class `std::vector`. +However, `std::vector<>` provides the semantics of dynamic arrays. +Thus, it manages data to be able to change the number of elements. +This results in some overhead in case only arrays with static size are needed. + +In his book, _Generic Programming and the STL_, Matthew H. Austern introduces a useful wrapper class for ordinary arrays with static size, called `block`. +It is safer and has no worse performance than ordinary arrays. +In _The {cpp} Programming Language_, 3rd edition, Bjarne Stroustrup introduces a similar class, called c_array, which I (http://www.josuttis.com/[Nicolai Josuttis]) present slightly modified in my book _The {cpp} Standard Library - A Tutorial and Reference_, called `carray`. +This is the essence of these approaches spiced with many feedback from https://www.boost.org/[Boost]. After considering different names, we decided to name this class simply `array`. diff --git a/doc/array/reference.adoc b/doc/array/reference.adoc index bde92669..5e80a0e8 100644 --- a/doc/array/reference.adoc +++ b/doc/array/reference.adoc @@ -15,24 +15,30 @@ https://www.boost.org/LICENSE_1_0.txt ```cpp namespace boost { + template class array; - template void swap(array&, array&); + + template + constexpr void swap(array&, array&); + template - bool operator==(const array&, const array&); + constexpr bool operator==(const array&, const array&); template - bool operator!=(const array&, const array&); + constexpr bool operator!=(const array&, const array&); + template - bool operator<(const array&, const array&); + constexpr bool operator<(const array&, const array&); template - bool operator>(const array&, const array&); + constexpr bool operator>(const array&, const array&); template - bool operator<=(const array&, const array&); + constexpr bool operator<=(const array&, const array&); template - bool operator>=(const array&, const array&); - template - T boost::get(array&); - template - T boost::get(const array&); + constexpr bool operator>=(const array&, const array&); + + template + constexpr T& get(array&) noexcept; + template + constexpr const T& get(const array&) noexcept; } ``` @@ -46,7 +52,9 @@ namespace boost { template class array { public: + // types + typedef T value_type; typedef T* iterator; typedef const T* const_iterator; @@ -58,361 +66,340 @@ public: typedef std::ptrdiff_t difference_type; // static constants + static const size_type static_size = N; - // construct/copy/destruct + // construct/copy/destroy + template array& operator=(const array&); // iterator support - iterator begin(); - const_iterator begin() const; - iterator end(); - const_iterator end() const; - const_iterator cbegin(); - const_iterator cend(); + + constexpr iterator begin() noexcept; + constexpr const_iterator begin() const noexcept; + constexpr const_iterator cbegin() const noexcept; + + constexpr iterator end() noexcept; + constexpr const_iterator end() const noexcept; + constexpr const_iterator cend() const noexcept; // reverse iterator support - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; - reverse_iterator rend(); - const_reverse_iterator rend() const; - const_reverse_iterator crbegin(); - const_reverse_iterator crend(); + + reverse_iterator rbegin() noexcept; + const_reverse_iterator rbegin() const noexcept; + const_reverse_iterator crbegin() const noexcept; + + reverse_iterator rend() noexcept; + const_reverse_iterator rend() const noexcept; + const_reverse_iterator crend() const noexcept; // capacity - size_type size(); - bool empty(); - size_type max_size(); + + static constexpr size_type size() noexcept; + static constexpr bool empty() noexcept; + static constexpr size_type max_size() noexcept; // element access - reference operator[](size_type); - const_reference operator[](size_type) const; - reference at(size_type); - const_reference at(size_type) const; - reference front(); - const_reference front() const; - reference back(); - const_reference back() const; - const T* data() const; - T* c_array(); + + constexpr reference operator[](size_type); + constexpr const_reference operator[](size_type) const; + + constexpr reference at(size_type); + constexpr const_reference at(size_type) const; + + constexpr reference front(); + constexpr const_reference front() const; + + constexpr reference back(); + constexpr const_reference back() const; + + constexpr T* data() noexcept; + constexpr const T* data() const noexcept; + + T* c_array() noexcept; // deprecated // modifiers - void swap(array&); - void assign(const T&); + + constexpr void swap(array&); + + constexpr void fill(const T&); + void assign(const T&); // deprecated // public data members T elems[N]; }; - -// specialized algorithms -template void swap(array&, array&); - -// comparisons -template - bool operator==(const array&, const array&); -template - bool operator!=(const array&, const array&); -template - bool operator<(const array&, const array&); -template - bool operator>(const array&, const array&); -template - bool operator<=(const array&, const array&); -template - bool operator>=(const array&, const array&); - -// specializations -template - T boost::get(array&); -template - T boost::get(const array&); ``` -### Description - -#### array public construct/copy/destruct +### Construct/Copy/Destroy ``` template array& operator=(const array& other); ``` [horizontal] -Effects: :: `std::copy(rhs.begin(), rhs.end(), begin())` +Effects: :: `std::copy(rhs.begin(), rhs.end(), begin())`. --- -#### array iterator support +### Iterator Support ``` -iterator begin(); -const_iterator begin() const; +constexpr iterator begin() noexcept; +constexpr const_iterator begin() const noexcept; +constexpr const_iterator cbegin() const noexcept; ``` [horizontal] -Returns: :: iterator for the first element -Throws: :: will not throw +Returns: :: `data()`. --- ``` -iterator end(); -const_iterator end() const; +constexpr iterator end() noexcept; +constexpr const_iterator end() const noexcept; +constexpr const_iterator cend() const noexcept; ``` [horizontal] -Returns: :: iterator for position after the last element -Throws: :: will not throw +Returns: :: `data() + size()`. --- -``` -const_iterator cbegin(); -``` -[horizontal] -Returns: :: constant iterator for the first element -Throws: :: will not throw - ---- +### Reverse Iterator Support ``` -const_iterator cend(); +reverse_iterator rbegin() noexcept; ``` [horizontal] -Returns: :: constant iterator for position after the last element -Throws: :: will not throw +Returns: :: `reverse_iterator(end())`. --- -#### array reverse iterator support - ``` -reverse_iterator rbegin(); -const_reverse_iterator rbegin() const; +const_reverse_iterator rbegin() const noexcept; +const_reverse_iterator crbegin() const noexcept; ``` [horizontal] -Returns: :: reverse iterator for the first element of reverse iteration +Returns: :: `const_reverse_iterator(end())`. --- ``` -reverse_iterator rend(); -const_reverse_iterator rend() const; +reverse_iterator rend() noexcept; ``` [horizontal] -Returns: :: reverse iterator for position after the last element in reverse iteration +Returns: :: `reverse_iterator(begin())`. --- ``` -const_reverse_iterator crbegin(); +const_reverse_iterator rend() const noexcept; +const_reverse_iterator crend() const noexcept; ``` [horizontal] -Returns: :: constant reverse iterator for the first element of reverse iteration -Throws: :: will not throw +Returns: :: `const_reverse_iterator(begin())`. --- +### Capacity + ``` -const_reverse_iterator crend(); +static constexpr size_type size() noexcept; ``` [horizontal] -Returns: :: constant reverse iterator for position after the last element in reverse iteration -Throws: :: will not throw +Returns: :: `N`. --- -#### array capacity - ``` -size_type size(); +static constexpr bool empty() noexcept; ``` [horizontal] -Returns: :: `N` +Returns: :: `N == 0`. --- ``` -bool empty(); +static constexpr size_type max_size() noexcept; ``` [horizontal] -Returns: :: `N==0` -Throws: :: will not throw +Returns: :: `N`. --- +### Element Access + ``` -size_type max_size(); +constexpr reference operator[](size_type i); +constexpr const_reference operator[](size_type i) const; ``` [horizontal] -Returns: :: `N` -Throws: :: will not throw +Requires: :: `i < N`. +Returns: :: `elems[i]`. +Throws: :: nothing. --- -#### array element access - ``` -reference operator[](size_type i); -const_reference operator[](size_type i) const; +constexpr reference at(size_type i); +constexpr const_reference at(size_type i) const; ``` [horizontal] -Requires: :: `i < N` -Returns: :: element with index `i` -Throws: :: will not throw. +Returns: :: `elems[i]`. +Throws: :: `std::out_of_range` if `i >= N`. --- ``` -reference at(size_type i); -const_reference at(size_type i) const; +constexpr reference front(); +constexpr const_reference front() const; ``` [horizontal] -Returns: :: element with index `i` -Throws: :: `std::range_error` if `i >= N` +Requires: :: `N > 0`. +Returns: :: `elems[0]`. +Throws: :: nothing. --- ``` -reference front(); -const_reference front() const; +constexpr reference back(); +constexpr const_reference back() const; ``` [horizontal] -Requires: :: `N > 0` -Returns: :: the first element -Throws: :: will not throw +Requires: :: `N > 0`. +Returns: :: `elems[N-1]`. +Throws: :: nothing. --- ``` -reference back(); -const_reference back() const; +constexpr T* data() noexcept; +constexpr const T* data() const noexcept; ``` [horizontal] -Requires: :: `N > 0` -Returns: :: the last element -Throws: :: will not throw +Returns: :: `elems`. --- ``` -const T* data() const; +T* c_array() noexcept; // deprecated ``` [horizontal] -Returns: :: `elems` -Throws: :: will not throw +Returns: :: `data()`. +Remarks: :: This function is deprecated. Use `data()` instead. --- +### Modifiers + ``` -T* c_array(); +constexpr void swap(array& other); ``` [horizontal] -Returns: :: `elems` -Throws: :: will not throw +Effects: :: for each `i` in `[0..N)`, calls `swap(elems[i], other.elems[i])`. +Complexity: :: linear in `N`. --- -#### array modifiers - ``` -void swap(array& other); +void fill(const T& value); ``` [horizontal] -Effects: :: `std::swap_ranges(begin(), end(), other.begin())` -Complexity: :: linear in `N` +Effects: :: for each `i` in `[0..N)`, performs `elems[i] = value;`. --- ``` -void assign(const T& value); +void assign(const T& value); // deprecated ``` [horizontal] -Effects: :: `std::fill_n(begin(), N, value)` +Effects: :: `fill(value)`. +Remarks: :: An obsolete and deprecated spelling of `fill`. Use `fill` instead. --- -#### array specialized algorithms +### Specialized Algorithms ``` -template void swap(array& x, array& y); +template + constexpr void swap(array& x, array& y); ``` [horizontal] -Effects: :: `x.swap(y)` -Throws: :: will not throw. +Effects: :: `x.swap(y)`. --- -#### array comparisons +### Comparisons ``` template - bool operator==(const array& x, const array& y); + constexpr bool operator==(const array& x, const array& y); ``` [horizontal] -Returns: :: `std::equal(x.begin(), x.end(), y.begin())` +Returns: :: `std::equal(x.begin(), x.end(), y.begin())`. --- ``` template - bool operator!=(const array& x, const array& y); + constexpr bool operator!=(const array& x, const array& y); ``` [horizontal] -Returns: :: `!(x == y)` +Returns: :: `!(x == y)`. --- ``` template - bool operator<(const array& x, const array& y); + constexpr bool operator<(const array& x, const array& y); ``` [horizontal] -Returns: :: `std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end())` +Returns: :: `std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end())`. --- ``` template - bool operator>(const array& x, const array& y); + constexpr bool operator>(const array& x, const array& y); ``` [horizontal] -Returns: :: `y < x` +Returns: :: `y < x`. --- ``` template - bool operator<=(const array& x, const array& y); + constexpr bool operator<=(const array& x, const array& y); ``` [horizontal] -Returns: :: `!(y < x)` +Returns: :: `!(y < x)`. --- ``` template - bool operator>=(const array& x, const array& y); + constexpr bool operator>=(const array& x, const array& y); ``` [horizontal] -Returns: :: `!(x < y)` +Returns: :: `!(x < y)`. --- -#### array specializations +### Specializations ``` -template - T boost::get(array& arr); +template + constexpr T& get(array& arr) noexcept; ``` [horizontal] -Returns: :: element of array with index `Idx` -Effects: :: Will `static_assert` if `Idx >= N` +Mandates: :: `Idx < N`. +Returns: :: `arr[Idx]`. --- ``` -template - T boost::get(const array& arr); +template + constexpr const T& get(const array& arr) noexcept; ``` [horizontal] -Returns: :: const element of array with index `Idx` -Effects: :: Will `static_assert` if `Idx >= N` +Mandates: :: `Idx < N`. +Returns: :: `arr[Idx]`. --- From 52406dfcc03e044ef8b157b0fd6a94fc931216c4 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 18:06:00 +0200 Subject: [PATCH 086/154] Add revision history --- doc/array.adoc | 1 + doc/array/changes.adoc | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 doc/array/changes.adoc diff --git a/doc/array.adoc b/doc/array.adoc index 66a90baf..a7e867d2 100644 --- a/doc/array.adoc +++ b/doc/array.adoc @@ -19,6 +19,7 @@ Nicolai M. Josuttis :leveloffset: +1 include::array/introduction.adoc[] +include::array/changes.adoc[] include::array/reference.adoc[] include::array/design_rationale.adoc[] include::array/information.adoc[] diff --git a/doc/array/changes.adoc b/doc/array/changes.adoc new file mode 100644 index 00000000..9133d6f0 --- /dev/null +++ b/doc/array/changes.adoc @@ -0,0 +1,16 @@ +//// +Copyright 2025 Peter Dimov +Distributed under the Boost Software License, Version 1.0. +http://www.boost.org/LICENSE_1_0.txt +//// + +[#changes] +# Revision History +:toc: +:toc-title: +:idprefix: + +## Changes in 1.88.0 + +* Converted documentation to AsciiDoc (Christian Mazakas). +* Added `noexcept` and `constexpr` as appropriate. From e7663434eef96c72b6093b565d802f5a718f4797 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 19:18:22 +0200 Subject: [PATCH 087/154] Add array_init_test_cx.cpp --- test/Jamfile.v2 | 4 ++ test/array_init_test_cx.cpp | 74 +++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 test/array_init_test_cx.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 19f857e3..551e8e7c 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -49,4 +49,8 @@ run array_get_test.cpp ; # +compile array_init_test_cx.cpp ; + +# + run quick.cpp ; diff --git a/test/array_init_test_cx.cpp b/test/array_init_test_cx.cpp new file mode 100644 index 00000000..1df53f50 --- /dev/null +++ b/test/array_init_test_cx.cpp @@ -0,0 +1,74 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX11_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template void test1() +{ + constexpr boost::array a = {{}}; + + STATIC_ASSERT( a[0] == 0 ); +} + +template void test2() +{ + constexpr boost::array a = {}; + + STATIC_ASSERT( a[0] == 0 ); + STATIC_ASSERT( a[1] == 0 ); +} + +template void test3() +{ + constexpr boost::array a = {{ 1, 2, 3 }}; + + STATIC_ASSERT( a[0] == 1 ); + STATIC_ASSERT( a[1] == 2 ); + STATIC_ASSERT( a[2] == 3 ); +} + +template void test4() +{ + constexpr boost::array a = { 1, 2, 3, 4 }; + + STATIC_ASSERT( a[0] == 1 ); + STATIC_ASSERT( a[1] == 2 ); + STATIC_ASSERT( a[2] == 3 ); + STATIC_ASSERT( a[3] == 4 ); +} + +template void test5() +{ + // constexpr boost::array a = {{}}; +} + +template void test6() +{ + constexpr boost::array a = {}; + (void)a; +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); +} + +#endif From 54d839c8bc1d41d141be2825b7d5d1cef147f436 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 19:23:50 +0200 Subject: [PATCH 088/154] Add array_size_test_cx.cpp --- test/Jamfile.v2 | 1 + test/array_size_test_cx.cpp | 64 +++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 test/array_size_test_cx.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 551e8e7c..f982ec25 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -50,6 +50,7 @@ run array_get_test.cpp ; # compile array_init_test_cx.cpp ; +compile array_size_test_cx.cpp ; # diff --git a/test/array_size_test_cx.cpp b/test/array_size_test_cx.cpp new file mode 100644 index 00000000..bfa4f40f --- /dev/null +++ b/test/array_size_test_cx.cpp @@ -0,0 +1,64 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX11_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template void test1() +{ + constexpr boost::array a = {}; + + STATIC_ASSERT( a.size() == N ); + STATIC_ASSERT( a.empty() == (N == 0) ); + STATIC_ASSERT( a.max_size() == N ); +} + +template void test2() +{ + typedef boost::array A; + + STATIC_ASSERT( A().size() == N ); + STATIC_ASSERT( A().empty() == (N == 0) ); + STATIC_ASSERT( A().max_size() == N ); +} + +// the functions are static, which deviates from the standard +template void test3() +{ + typedef boost::array A; + + STATIC_ASSERT( A::size() == N ); + STATIC_ASSERT( A::empty() == (N == 0) ); + STATIC_ASSERT( A::max_size() == N ); + + STATIC_ASSERT( A::static_size == N ); +} + +int main() +{ + test1(); + test1(); + test1(); + + test2(); + test2(); + test2(); + + test3(); + test3(); + test3(); +} + +#endif From 66386e8eda640ed750f6485e32e5d2e476e50af3 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 19:29:47 +0200 Subject: [PATCH 089/154] Add array_copy_test_cx.cpp --- test/Jamfile.v2 | 1 + test/array_copy_test_cx.cpp | 54 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 test/array_copy_test_cx.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f982ec25..fa88cbe6 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -50,6 +50,7 @@ run array_get_test.cpp ; # compile array_init_test_cx.cpp ; +compile array_copy_test_cx.cpp ; compile array_size_test_cx.cpp ; # diff --git a/test/array_copy_test_cx.cpp b/test/array_copy_test_cx.cpp new file mode 100644 index 00000000..f8f1c737 --- /dev/null +++ b/test/array_copy_test_cx.cpp @@ -0,0 +1,54 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX11_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template void test1() +{ + constexpr boost::array a1 = {}; + constexpr boost::array a2 = a1; + + STATIC_ASSERT( a1[0] == a2[0] ); + STATIC_ASSERT( a1[1] == a2[1] ); +} + +template void test2() +{ + constexpr boost::array a1 = {{ 1, 2, 3 }}; + constexpr boost::array a2 = a1; + + STATIC_ASSERT( a1[0] == a2[0] ); + STATIC_ASSERT( a1[1] == a2[1] ); + STATIC_ASSERT( a1[2] == a2[2] ); +} + +template void test3() +{ + constexpr boost::array a1 = {}; + constexpr boost::array a2 = a1; + + (void)a1; + (void)a2; +} + +int main() +{ + test1(); + test2(); + test3(); +} + +#endif From 19f02c76157bc98c232d3edaa1a4649243e99a31 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 19:38:01 +0200 Subject: [PATCH 090/154] Add array_data_test_cx.cpp --- test/Jamfile.v2 | 1 + test/array_data_test_cx.cpp | 39 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 test/array_data_test_cx.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index fa88cbe6..d940e561 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -51,6 +51,7 @@ run array_get_test.cpp ; compile array_init_test_cx.cpp ; compile array_copy_test_cx.cpp ; +compile array_data_test_cx.cpp ; compile array_size_test_cx.cpp ; # diff --git a/test/array_data_test_cx.cpp b/test/array_data_test_cx.cpp new file mode 100644 index 00000000..4b4e0f5a --- /dev/null +++ b/test/array_data_test_cx.cpp @@ -0,0 +1,39 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX11_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template void test1() +{ + constexpr boost::array a = {}; + STATIC_ASSERT( a.data() == a.elems ); +} + +template void test2() +{ + constexpr boost::array a = {}; + STATIC_ASSERT( a.data() == 0 ); +} + +int main() +{ + test1(); + test1(); + + test2(); +} + +#endif From 7ca2f112a2ea906be977fdf0fc16a69e19b2ac60 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 19:42:21 +0200 Subject: [PATCH 091/154] Disable constexpr data() test for msvc-14.0 --- test/array_data_test_cx.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/array_data_test_cx.cpp b/test/array_data_test_cx.cpp index 4b4e0f5a..fcb749f9 100644 --- a/test/array_data_test_cx.cpp +++ b/test/array_data_test_cx.cpp @@ -12,6 +12,10 @@ BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") +#elif BOOST_WORKAROUND(BOOST_MSVC, < 1910) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_MSVC < 1910") + #else #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) From f1558317958c48393f8bcb115e921a7e48c756b9 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 20:02:57 +0200 Subject: [PATCH 092/154] Add array_iterator_test_cx.cpp --- test/Jamfile.v2 | 1 + test/array_iterator_test_cx.cpp | 54 +++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 test/array_iterator_test_cx.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d940e561..58dc7613 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -52,6 +52,7 @@ run array_get_test.cpp ; compile array_init_test_cx.cpp ; compile array_copy_test_cx.cpp ; compile array_data_test_cx.cpp ; +compile array_iterator_test_cx.cpp ; compile array_size_test_cx.cpp ; # diff --git a/test/array_iterator_test_cx.cpp b/test/array_iterator_test_cx.cpp new file mode 100644 index 00000000..e1bdc85a --- /dev/null +++ b/test/array_iterator_test_cx.cpp @@ -0,0 +1,54 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX11_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") + +#elif BOOST_WORKAROUND(BOOST_MSVC, < 1910) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_MSVC < 1910") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template void test1() +{ + constexpr boost::array a = {}; + + STATIC_ASSERT( a.begin() == a.data() ); + STATIC_ASSERT( a.end() == a.data() + N ); + + STATIC_ASSERT( a.cbegin() == a.data() ); + STATIC_ASSERT( a.cend() == a.data() + N ); +} + +template void test2() +{ + constexpr boost::array a = {}; + + // iterator access is not constexpr for boost::array + // it is for std::array, though, so we should change it + + STATIC_ASSERT( a.begin() == a.end() ); + STATIC_ASSERT( a.cbegin() == a.cend() ); +} + +int main() +{ + // test1(); + test1(); + test1(); + + // test2(); +} + +#endif From c06cadc04f74230cd25ba48d5515499e758c14c6 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 20:09:17 +0200 Subject: [PATCH 093/154] Add array_access_test_cx.cpp --- test/Jamfile.v2 | 1 + test/array_access_test_cx.cpp | 46 +++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 test/array_access_test_cx.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 58dc7613..1c65f9ee 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -54,6 +54,7 @@ compile array_copy_test_cx.cpp ; compile array_data_test_cx.cpp ; compile array_iterator_test_cx.cpp ; compile array_size_test_cx.cpp ; +compile array_access_test_cx.cpp ; # diff --git a/test/array_access_test_cx.cpp b/test/array_access_test_cx.cpp new file mode 100644 index 00000000..a5534db5 --- /dev/null +++ b/test/array_access_test_cx.cpp @@ -0,0 +1,46 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX11_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") + +#elif BOOST_WORKAROUND(BOOST_MSVC, < 1910) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_MSVC < 1910") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template void test() +{ + constexpr boost::array a = {{}}; + + STATIC_ASSERT( &a[ 0 ] == a.data() + 0 ); + STATIC_ASSERT( &a[ 1 ] == a.data() + 1 ); + STATIC_ASSERT( &a[ 2 ] == a.data() + 2 ); + STATIC_ASSERT( &a[ 3 ] == a.data() + 3 ); + + STATIC_ASSERT( &a.at( 0 ) == a.data() + 0 ); + STATIC_ASSERT( &a.at( 1 ) == a.data() + 1 ); + STATIC_ASSERT( &a.at( 2 ) == a.data() + 2 ); + STATIC_ASSERT( &a.at( 3 ) == a.data() + 3 ); + + STATIC_ASSERT( &a.front() == a.data() ); + STATIC_ASSERT( &a.back() == a.data() + 3 ); +} + +int main() +{ + test(); +} + +#endif From a2114688667bab5959336bc52e7dd7a4b9623253 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 20:24:15 +0200 Subject: [PATCH 094/154] Add array_eq_test_cx.cpp --- include/boost/array.hpp | 23 +++++++++++----- test/Jamfile.v2 | 6 ++++- test/array_eq_test_cx.cpp | 55 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 test/array_eq_test_cx.cpp diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 2ecd800e..6266ddc2 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -321,25 +321,36 @@ namespace boost { // comparisons template - BOOST_CXX14_CONSTEXPR bool operator== (const array& x, const array& y) { - return std::equal(x.begin(), x.end(), y.begin()); - } - template - BOOST_CXX14_CONSTEXPR bool operator< (const array& x, const array& y) { - return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); + BOOST_CXX14_CONSTEXPR bool operator== (const array& x, const array& y) + { + for( std::size_t i = 0; i < N; ++i ) + { + if( !( x[ i ] == y[ i ] ) ) return false; + } + + return true; } + template BOOST_CXX14_CONSTEXPR bool operator!= (const array& x, const array& y) { return !(x==y); } + + template + BOOST_CXX14_CONSTEXPR bool operator< (const array& x, const array& y) { + return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); + } + template BOOST_CXX14_CONSTEXPR bool operator> (const array& x, const array& y) { return y BOOST_CXX14_CONSTEXPR bool operator<= (const array& x, const array& y) { return !(y BOOST_CXX14_CONSTEXPR bool operator>= (const array& x, const array& y) { return !(x +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX14_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template void test1() +{ + constexpr boost::array a1 = {}; + constexpr boost::array a2 = {}; + + STATIC_ASSERT( a1 == a2 ); + STATIC_ASSERT( !( a1 != a2 ) ); +} + +template void test2() +{ + { + constexpr boost::array a1 = {{ 1, 2, 3, 4 }}; + constexpr boost::array a2 = {{ 1, 2, 3, 4 }}; + + STATIC_ASSERT( a1 == a2 ); + STATIC_ASSERT( !( a1 != a2 ) ); + } + { + constexpr boost::array a1 = {{ 1, 2, 3, 4 }}; + constexpr boost::array a2 = {{ 1, 2, 3, 5 }}; + + STATIC_ASSERT( !( a1 == a2 ) ); + STATIC_ASSERT( a1 != a2 ); + } +} + +int main() +{ + test1(); + test1(); + test1(); + + test2(); +} + +#endif From 5c05254afbad14509fade257bb7160404376305e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 20:32:38 +0200 Subject: [PATCH 095/154] Add array_lt_test_cx.cpp --- include/boost/array.hpp | 11 ++++-- test/Jamfile.v2 | 1 + test/array_lt_test_cx.cpp | 74 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 test/array_lt_test_cx.cpp diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 6266ddc2..0506326e 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -337,8 +337,15 @@ namespace boost { } template - BOOST_CXX14_CONSTEXPR bool operator< (const array& x, const array& y) { - return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); + BOOST_CXX14_CONSTEXPR bool operator< (const array& x, const array& y) + { + for( std::size_t i = 0; i < N; ++i ) + { + if( x[ i ] < y[ i ] ) return true; + if( y[ i ] < x[ i ] ) return false; + } + + return false; } template diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index ad3173ed..2a41c8fa 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -59,6 +59,7 @@ compile array_access_test_cx.cpp ; # C++14 constexpr compile array_eq_test_cx.cpp ; +compile array_lt_test_cx.cpp ; # diff --git a/test/array_lt_test_cx.cpp b/test/array_lt_test_cx.cpp new file mode 100644 index 00000000..d01c9e45 --- /dev/null +++ b/test/array_lt_test_cx.cpp @@ -0,0 +1,74 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX14_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template void test1() +{ + constexpr boost::array a1 = {}; + constexpr boost::array a2 = {}; + + STATIC_ASSERT( !( a1 < a2 ) ); + STATIC_ASSERT( !( a1 > a2 ) ); + + STATIC_ASSERT( a1 <= a2 ); + STATIC_ASSERT( a1 >= a2 ); +} + +template void test2() +{ + { + constexpr boost::array a1 = {{ 1, 2, 3, 4 }}; + constexpr boost::array a2 = {{ 1, 2, 3, 4 }}; + + STATIC_ASSERT( !( a1 < a2 ) ); + STATIC_ASSERT( !( a1 > a2 ) ); + + STATIC_ASSERT( a1 <= a2 ); + STATIC_ASSERT( a1 >= a2 ); + } + { + constexpr boost::array a1 = {{ 1, 2, 3, 4 }}; + constexpr boost::array a2 = {{ 1, 2, 3, 5 }}; + + STATIC_ASSERT( a1 < a2 ); + STATIC_ASSERT( !( a1 > a2 ) ); + + STATIC_ASSERT( a1 <= a2 ); + STATIC_ASSERT( !( a1 >= a2 ) ); + } + { + constexpr boost::array a1 = {{ 1, 2, 3, 4 }}; + constexpr boost::array a2 = {{ 1, 2, 3, 2 }}; + + STATIC_ASSERT( !( a1 < a2 ) ); + STATIC_ASSERT( a1 > a2 ); + + STATIC_ASSERT( !( a1 <= a2 ) ); + STATIC_ASSERT( a1 >= a2 ); + } +} + +int main() +{ + test1(); + test1(); + test1(); + + test2(); +} + +#endif From ea9dbd56743a4819ebf3b9deeae26bbf95752883 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 20:46:20 +0200 Subject: [PATCH 096/154] Disable array_init_test_cx for GCC 4.x --- test/array_init_test_cx.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/array_init_test_cx.cpp b/test/array_init_test_cx.cpp index 1df53f50..b35fe71d 100644 --- a/test/array_init_test_cx.cpp +++ b/test/array_init_test_cx.cpp @@ -12,6 +12,10 @@ BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") +#elif BOOST_WORKAROUND(BOOST_GCC, < 50000) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_GCC < 50000") + #else #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) From b44be8da89f5c7055a84cb2efcb3a2b26ecca7da Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 20:47:36 +0200 Subject: [PATCH 097/154] Disable array_copy_test_cx for GCC 4.x --- test/array_copy_test_cx.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/array_copy_test_cx.cpp b/test/array_copy_test_cx.cpp index f8f1c737..9a4ab56e 100644 --- a/test/array_copy_test_cx.cpp +++ b/test/array_copy_test_cx.cpp @@ -12,6 +12,10 @@ BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") +#elif BOOST_WORKAROUND(BOOST_GCC, < 50000) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_GCC < 50000") + #else #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) From 18ec6239b28871c37e5bc39a0e839d2053418c1c Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 20:49:14 +0200 Subject: [PATCH 098/154] Disable array_data_test_cx for GCC 4.x --- test/array_data_test_cx.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/array_data_test_cx.cpp b/test/array_data_test_cx.cpp index fcb749f9..a9f8322c 100644 --- a/test/array_data_test_cx.cpp +++ b/test/array_data_test_cx.cpp @@ -16,6 +16,10 @@ BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_MSVC < 1910") +#elif BOOST_WORKAROUND(BOOST_GCC, < 50000) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_GCC < 50000") + #else #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) From ec05d6ca3442e52210e16cd416128c4d51552326 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 20:50:45 +0200 Subject: [PATCH 099/154] Disable array_iterator_test_cx for GCC 4.x --- test/array_iterator_test_cx.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/array_iterator_test_cx.cpp b/test/array_iterator_test_cx.cpp index e1bdc85a..10eef677 100644 --- a/test/array_iterator_test_cx.cpp +++ b/test/array_iterator_test_cx.cpp @@ -16,6 +16,10 @@ BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_MSVC < 1910") +#elif BOOST_WORKAROUND(BOOST_GCC, < 50000) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_GCC < 50000") + #else #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) From 50cf6ebba792e81054da4bfdccf0ab93811e58f5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 20:51:36 +0200 Subject: [PATCH 100/154] Disable array_access_test_cx for GCC 4.x --- test/array_access_test_cx.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/array_access_test_cx.cpp b/test/array_access_test_cx.cpp index a5534db5..0018d95c 100644 --- a/test/array_access_test_cx.cpp +++ b/test/array_access_test_cx.cpp @@ -16,6 +16,10 @@ BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_MSVC < 1910") +#elif BOOST_WORKAROUND(BOOST_GCC, < 50000) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_GCC < 50000") + #else #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) From b32a6cfcfda0e8ef71fabbe3c5bfee1ae306cf94 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 20:59:46 +0200 Subject: [PATCH 101/154] Work around GCC 5..8 constexpr comparison failures --- include/boost/array.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 0506326e..7c40dfbe 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -331,6 +331,16 @@ namespace boost { return true; } +#if BOOST_WORKAROUND(BOOST_GCC, < 90000) + + template + BOOST_CXX14_CONSTEXPR bool operator== (const array& x, const array& y) + { + return true; + } + +#endif + template BOOST_CXX14_CONSTEXPR bool operator!= (const array& x, const array& y) { return !(x==y); @@ -348,6 +358,16 @@ namespace boost { return false; } +#if BOOST_WORKAROUND(BOOST_GCC, < 90000) + + template + BOOST_CXX14_CONSTEXPR bool operator< (const array& x, const array& y) + { + return false; + } + +#endif + template BOOST_CXX14_CONSTEXPR bool operator> (const array& x, const array& y) { return y Date: Sat, 25 Jan 2025 21:20:12 +0200 Subject: [PATCH 102/154] Add array_get_test_cx.cpp --- include/boost/array.hpp | 4 ++-- test/Jamfile.v2 | 1 + test/array_get_test_cx.cpp | 42 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 test/array_get_test_cx.cpp diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 7c40dfbe..4b76a15c 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -458,13 +458,13 @@ namespace boost { } template - T &get(boost::array &arr) BOOST_NOEXCEPT { + BOOST_CXX14_CONSTEXPR T &get(boost::array &arr) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" ); return arr[Idx]; } template - const T &get(const boost::array &arr) BOOST_NOEXCEPT { + BOOST_CONSTEXPR const T &get(const boost::array &arr) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(const boost::array &) index out of range" ); return arr[Idx]; } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 2a41c8fa..4236865b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -55,6 +55,7 @@ compile array_data_test_cx.cpp ; compile array_iterator_test_cx.cpp ; compile array_size_test_cx.cpp ; compile array_access_test_cx.cpp ; +compile array_get_test_cx.cpp ; # C++14 constexpr diff --git a/test/array_get_test_cx.cpp b/test/array_get_test_cx.cpp new file mode 100644 index 00000000..eb7f1174 --- /dev/null +++ b/test/array_get_test_cx.cpp @@ -0,0 +1,42 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX11_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") + +#elif BOOST_WORKAROUND(BOOST_MSVC, < 1910) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_MSVC < 1910") + +#elif BOOST_WORKAROUND(BOOST_GCC, < 50000) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_GCC < 50000") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template void test() +{ + constexpr boost::array a = {{ 1, 2, 3, 4 }}; + + STATIC_ASSERT( boost::get<0>( a ) == 1 ); + STATIC_ASSERT( boost::get<1>( a ) == 2 ); + STATIC_ASSERT( boost::get<2>( a ) == 3 ); + STATIC_ASSERT( boost::get<3>( a ) == 4 ); +} + +int main() +{ + test(); +} + +#endif From 9e2868f8e27194ed1eca1cbb62289043c61c45ca Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 23:10:41 +0200 Subject: [PATCH 103/154] Reorder includes --- include/boost/array.hpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 4b76a15c..2a3c3046 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -1,3 +1,6 @@ +#ifndef BOOST_ARRAY_HPP_INCLUDED +#define BOOST_ARRAY_HPP_INCLUDED + /* The following code declares class array, * an STL container (as wrapper) for arrays of constant size. * @@ -28,8 +31,6 @@ * * Jan 29, 2004 */ -#ifndef BOOST_ARRAY_HPP -#define BOOST_ARRAY_HPP #include #include @@ -41,16 +42,14 @@ # pragma warning(disable:4610) // warning C4610: class 'boost::array' can never be instantiated - user defined constructor required #endif -#include -#include -#include #include #include #include - #include #include - +#include +#include +#include namespace boost { @@ -492,4 +491,4 @@ namespace std { # pragma warning(pop) #endif -#endif /*BOOST_ARRAY_HPP*/ +#endif // #ifndef BOOST_ARRAY_HPP_INCLUDED From f5a3f1b34a0603cfc9cfb74dbe5afeea333840ff Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 23:12:34 +0200 Subject: [PATCH 104/154] Remove obsolete reverse_iterator workarounds --- include/boost/array.hpp | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 2a3c3046..b6c175fb 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -78,19 +78,8 @@ namespace boost { BOOST_CONSTEXPR const_iterator cend() const BOOST_NOEXCEPT { return elems+N; } // reverse iterator support -#if !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; -#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; -#else - // workaround for broken reverse_iterator implementations - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; -#endif reverse_iterator rbegin() BOOST_NOEXCEPT { return reverse_iterator(end()); } const_reverse_iterator rbegin() const BOOST_NOEXCEPT { @@ -210,19 +199,8 @@ namespace boost { const_iterator cend() const BOOST_NOEXCEPT { return cbegin(); } // reverse iterator support -#if !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_NO_STD_ITERATOR_TRAITS) typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; -#elif defined(_RWSTD_NO_CLASS_PARTIAL_SPEC) - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; -#else - // workaround for broken reverse_iterator implementations - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; -#endif reverse_iterator rbegin() BOOST_NOEXCEPT { return reverse_iterator(end()); } const_reverse_iterator rbegin() const BOOST_NOEXCEPT { From 16b6ba8d8433b53116b4006e5eaec80a3d9d24de Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 23:20:31 +0200 Subject: [PATCH 105/154] Mark c_array as deprecated --- include/boost/array.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index b6c175fb..2e3588dd 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -148,11 +148,12 @@ namespace boost { boost::core::invoke_swap(elems[i],y.elems[i]); } - // direct access to data (read-only) + // direct access to data BOOST_CONSTEXPR const T* data() const BOOST_NOEXCEPT { return elems; } BOOST_CXX14_CONSTEXPR T* data() BOOST_NOEXCEPT { return elems; } - // use array as C array (direct read/write access to data) + // obsolete + BOOST_DEPRECATED( "please use `data()` instead" ) T* c_array() BOOST_NOEXCEPT { return elems; } // assignment with type conversion @@ -263,11 +264,12 @@ namespace boost { void swap (array& /*y*/) { } - // direct access to data (read-only) + // direct access to data BOOST_CONSTEXPR const T* data() const BOOST_NOEXCEPT { return 0; } BOOST_CXX14_CONSTEXPR T* data() BOOST_NOEXCEPT { return 0; } - // use array as C array (direct read/write access to data) + // obsolete + BOOST_DEPRECATED( "please use `data()` instead" ) T* c_array() BOOST_NOEXCEPT { return 0; } // assignment with type conversion From 16280f660ba79b1632067885144e40bedd4dfac5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 03:06:28 +0200 Subject: [PATCH 106/154] Mark `assign` as deprecated --- include/boost/array.hpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 2e3588dd..19cd5061 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -163,13 +163,16 @@ namespace boost { return *this; } - // assign one value to all elements - void assign (const T& value) { fill ( value ); } // A synonym for fill + // fill with one value BOOST_CXX14_CONSTEXPR void fill (const T& value) { std::fill_n(begin(),size(),value); } + // an obsolete synonym for fill + BOOST_DEPRECATED( "please use `fill` instead" ) + void assign (const T& value) { fill ( value ); } + // check range (may be private because it is static) static BOOST_CONSTEXPR bool rangecheck (size_type i) { return i >= size() ? boost::throw_exception(std::out_of_range ("array<>: index out of range")), true : true; @@ -278,8 +281,11 @@ namespace boost { return *this; } - // assign one value to all elements + // an obsolete synonym for fill + BOOST_DEPRECATED( "please use `fill` instead" ) void assign (const T& value) { fill ( value ); } + + // fill with one value BOOST_CXX14_CONSTEXPR void fill (const T& ) {} // check range (may be private because it is static) From fe60e163c74e4be3279a8fa538e6097fccdb31cb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 03:07:53 +0200 Subject: [PATCH 107/154] Remove obsolete Sun workaround --- include/boost/array.hpp | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 19cd5061..82d759e6 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -374,33 +374,6 @@ namespace boost { x.swap(y); } -#if defined(__SUNPRO_CC) -// Trac ticket #4757; the Sun Solaris compiler can't handle -// syntax like 'T(&get_c_array(boost::array& arg))[N]' -// -// We can't just use this for all compilers, because the -// borland compilers can't handle this form. - namespace detail { - template struct c_array - { - typedef T type[N]; - }; - } - - // Specific for boost::array: simply returns its elems data member. - template - typename detail::c_array::type& get_c_array(boost::array& arg) - { - return arg.elems; - } - - // Specific for boost::array: simply returns its elems data member. - template - typename detail::c_array::type const& get_c_array(const boost::array& arg) - { - return arg.elems; - } -#else // Specific for boost::array: simply returns its elems data member. template T(&get_c_array(boost::array& arg))[N] @@ -414,7 +387,6 @@ namespace boost { { return arg.elems; } -#endif #if 0 // Overload for std::array, assuming that std::array will have From 17b49d86ad37a7103ef62043c61f6bc4743ac6e7 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 03:10:23 +0200 Subject: [PATCH 108/154] Mark `get_c_array` as deprecated --- include/boost/array.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 82d759e6..d046c40f 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -374,8 +374,9 @@ namespace boost { x.swap(y); } -// Specific for boost::array: simply returns its elems data member. + // undocumented and obsolete template + BOOST_DEPRECATED( "please use `elems` instead" ) T(&get_c_array(boost::array& arg))[N] { return arg.elems; @@ -383,6 +384,7 @@ namespace boost { // Const version. template + BOOST_DEPRECATED( "please use `elems` instead" ) const T(&get_c_array(const boost::array& arg))[N] { return arg.elems; From 6447b408b2828d342f24d3680f6a8c6b2d4c01c5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 03:10:59 +0200 Subject: [PATCH 109/154] Remove idef-ed out overload of get_c_array --- include/boost/array.hpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index d046c40f..8486f9be 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -390,24 +390,6 @@ namespace boost { return arg.elems; } -#if 0 - // Overload for std::array, assuming that std::array will have - // explicit conversion functions as discussed at the WG21 meeting - // in Summit, March 2009. - template - T(&get_c_array(std::array& arg))[N] - { - return static_cast(arg); - } - - // Const version. - template - const T(&get_c_array(const std::array& arg))[N] - { - return static_cast(arg); - } -#endif - template std::size_t hash_range(It, It); template From 435b293467067e2a657b031be9d5533612ae9060 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 03:16:23 +0200 Subject: [PATCH 110/154] Mark `std::get` illegal overloads as deprecated --- include/boost/array.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 8486f9be..f0ebd9d5 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -416,12 +416,14 @@ namespace boost { // If we don't have std::array, I'm assuming that we don't have std::get namespace std { template + BOOST_DEPRECATED( "please use `boost::get` instead" ) T &get(boost::array &arr) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(boost::array &) index out of range" ); return arr[Idx]; } template + BOOST_DEPRECATED( "please use `boost::get` instead" ) const T &get(const boost::array &arr) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG ( Idx < N, "std::get<>(const boost::array &) index out of range" ); return arr[Idx]; From 55bc631d40d369347961e2e845fbdfc7f23e17c1 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 04:08:06 +0200 Subject: [PATCH 111/154] Remove use of core/invoke_swap --- include/boost/array.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index f0ebd9d5..b54cf06b 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -43,12 +43,12 @@ #endif #include -#include #include #include #include #include #include +#include #include namespace boost { @@ -143,9 +143,9 @@ namespace boost { enum { static_size = N }; // swap (note: linear complexity) - BOOST_CXX14_CONSTEXPR void swap (array& y) { - for (size_type i = 0; i < N; ++i) - boost::core::invoke_swap(elems[i],y.elems[i]); + BOOST_CXX14_CONSTEXPR void swap (array& y) + { + std::swap( elems, y.elems ); } // direct access to data @@ -264,7 +264,8 @@ namespace boost { static BOOST_CONSTEXPR size_type max_size() BOOST_NOEXCEPT { return 0; } enum { static_size = 0 }; - void swap (array& /*y*/) { + BOOST_CXX14_CONSTEXPR void swap (array& /*y*/) + { } // direct access to data @@ -370,7 +371,7 @@ namespace boost { // global swap() template - inline void swap (array& x, array& y) { + BOOST_CXX14_CONSTEXPR inline void swap (array& x, array& y) { x.swap(y); } From 6a9e8c78da12d232fa8233b5000dc337553036f0 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 04:11:14 +0200 Subject: [PATCH 112/154] Update documentation of `swap`. --- doc/array/reference.adoc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/array/reference.adoc b/doc/array/reference.adoc index 5e80a0e8..e2265de5 100644 --- a/doc/array/reference.adoc +++ b/doc/array/reference.adoc @@ -19,7 +19,7 @@ namespace boost { template class array; template - constexpr void swap(array&, array&); + void swap(array&, array&); template constexpr bool operator==(const array&, const array&); @@ -120,7 +120,7 @@ public: // modifiers - constexpr void swap(array&); + swap(array&); constexpr void fill(const T&); void assign(const T&); // deprecated @@ -290,10 +290,10 @@ Remarks: :: This function is deprecated. Use `data()` instead. ### Modifiers ``` -constexpr void swap(array& other); +void swap(array& other); ``` [horizontal] -Effects: :: for each `i` in `[0..N)`, calls `swap(elems[i], other.elems[i])`. +Effects: :: `std::swap(elems, other.elems)`. Complexity: :: linear in `N`. --- @@ -319,7 +319,7 @@ Remarks: :: An obsolete and deprecated spelling of `fill`. Use `fill` instead. ``` template - constexpr void swap(array& x, array& y); + void swap(array& x, array& y); ``` [horizontal] Effects: :: `x.swap(y)`. From cd0532b8fa858f15ae40191cc1428acbad1335fc Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 04:54:58 +0200 Subject: [PATCH 113/154] Remove inclusion of --- include/boost/array.hpp | 25 +++++++++++++++++++------ test/array0.cpp | 6 +++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index b54cf06b..9d251f74 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -37,15 +37,14 @@ #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) # pragma warning(push) -# pragma warning(disable:4996) // 'std::equal': Function call with parameters that may be unsafe # pragma warning(disable:4510) // boost::array' : default constructor could not be generated -# pragma warning(disable:4610) // warning C4610: class 'boost::array' can never be instantiated - user defined constructor required +# pragma warning(disable:4512) // boost::array' : assignment operator could not be generated +# pragma warning(disable:4610) // class 'boost::array' can never be instantiated - user defined constructor required #endif #include #include #include -#include #include #include #include @@ -158,15 +157,29 @@ namespace boost { // assignment with type conversion template - array& operator= (const array& rhs) { - std::copy(rhs.begin(),rhs.end(), begin()); + array& operator= (const array& rhs) + { + for( std::size_t i = 0; i < N; ++i ) + { + elems[ i ] = rhs.elems[ i ]; + } + return *this; } // fill with one value BOOST_CXX14_CONSTEXPR void fill (const T& value) { - std::fill_n(begin(),size(),value); + // using elems[ 0 ] as a temporary copy + // avoids the aliasing opportunity betw. + // `value` and `elems` + + elems[ 0 ] = value; + + for( std::size_t i = 1; i < N; ++i ) + { + elems[ i ] = elems[ 0 ]; + } } // an obsolete synonym for fill diff --git a/test/array0.cpp b/test/array0.cpp index af1d47bb..e3a62621 100644 --- a/test/array0.cpp +++ b/test/array0.cpp @@ -5,11 +5,11 @@ * http://www.boost.org/LICENSE_1_0.txt) */ -#include -#include #include - #include +#include +#include +#include namespace { From 9253e8f1af0aa1b99945859647e536a7c0739765 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 05:41:56 +0200 Subject: [PATCH 114/154] Add array_fill_test_cx.cpp --- test/Jamfile.v2 | 1 + test/array_fill_test_cx.cpp | 51 +++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 test/array_fill_test_cx.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 4236865b..1f928093 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -59,6 +59,7 @@ compile array_get_test_cx.cpp ; # C++14 constexpr +compile array_fill_test_cx.cpp ; compile array_eq_test_cx.cpp ; compile array_lt_test_cx.cpp ; diff --git a/test/array_fill_test_cx.cpp b/test/array_fill_test_cx.cpp new file mode 100644 index 00000000..c0c8d979 --- /dev/null +++ b/test/array_fill_test_cx.cpp @@ -0,0 +1,51 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX14_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template constexpr boost::array filled( T const& v ) +{ + boost::array r = {}; + + r.fill( v ); + + return r; +} + +template void test1() +{ + constexpr boost::array a1 = filled( 7 ); + + STATIC_ASSERT( a1[0] == 7 ); + STATIC_ASSERT( a1[1] == 7 ); + STATIC_ASSERT( a1[2] == 7 ); + STATIC_ASSERT( a1[3] == 7 ); +} + +template void test2() +{ + constexpr boost::array a1 = filled( 7 ); + + (void)a1; +} + +int main() +{ + test1(); + test2(); +} + +#endif From 324827cfc0a9042fdd6fe81bc02612b349bb4806 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 05:45:36 +0200 Subject: [PATCH 115/154] Add array_assign_test_cx.cpp --- test/Jamfile.v2 | 1 + test/array_assign_test_cx.cpp | 54 +++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 test/array_assign_test_cx.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1f928093..f002a89d 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -59,6 +59,7 @@ compile array_get_test_cx.cpp ; # C++14 constexpr +compile array_assign_test_cx.cpp ; compile array_fill_test_cx.cpp ; compile array_eq_test_cx.cpp ; compile array_lt_test_cx.cpp ; diff --git a/test/array_assign_test_cx.cpp b/test/array_assign_test_cx.cpp new file mode 100644 index 00000000..1314d4a3 --- /dev/null +++ b/test/array_assign_test_cx.cpp @@ -0,0 +1,54 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX14_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template constexpr boost::array assigned( boost::array const& a1 ) +{ + boost::array a2 = {}; + + a2 = a1; + + return a2; +} + +template void test1() +{ + constexpr boost::array a1 = {{ 1, 2, 3, 4 }}; + constexpr boost::array a2 = assigned( a1 ); + + STATIC_ASSERT( a1[0] == a2[0] ); + STATIC_ASSERT( a1[1] == a2[1] ); + STATIC_ASSERT( a1[2] == a2[2] ); + STATIC_ASSERT( a1[3] == a2[3] ); +} + +template void test2() +{ + constexpr boost::array a1 = {}; + constexpr boost::array a2 = assigned( a1 ); + + (void)a1; + (void)a2; +} + +int main() +{ + test1(); + test2(); +} + +#endif From d2c295b85fdf851c41804d52f5b528c965a7f05d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 05:53:09 +0200 Subject: [PATCH 116/154] Add array_access_test_cx2.cpp --- test/Jamfile.v2 | 1 + test/array_access_test_cx2.cpp | 45 ++++++++++++++++++++++++++++++++++ test/array_assign_test_cx.cpp | 2 +- test/array_fill_test_cx.cpp | 2 +- 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 test/array_access_test_cx2.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f002a89d..2e0ecb1a 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -60,6 +60,7 @@ compile array_get_test_cx.cpp ; # C++14 constexpr compile array_assign_test_cx.cpp ; +compile array_access_test_cx2.cpp ; compile array_fill_test_cx.cpp ; compile array_eq_test_cx.cpp ; compile array_lt_test_cx.cpp ; diff --git a/test/array_access_test_cx2.cpp b/test/array_access_test_cx2.cpp new file mode 100644 index 00000000..9e00fe0f --- /dev/null +++ b/test/array_access_test_cx2.cpp @@ -0,0 +1,45 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX14_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template constexpr boost::array modified( boost::array a1 ) +{ + a1.front() = 1; + a1[ 1 ] = 2; + a1.at( 2 ) = 3; + a1.back() = 4; + + return a1; +} + +template void test1() +{ + constexpr boost::array a1 = {}; + constexpr boost::array a2 = modified( a1 ); + + STATIC_ASSERT( a2[0] == 1 ); + STATIC_ASSERT( a2[1] == 2 ); + STATIC_ASSERT( a2[2] == 3 ); + STATIC_ASSERT( a2[3] == 4 ); +} + +int main() +{ + test1(); +} + +#endif diff --git a/test/array_assign_test_cx.cpp b/test/array_assign_test_cx.cpp index 1314d4a3..ce8031cd 100644 --- a/test/array_assign_test_cx.cpp +++ b/test/array_assign_test_cx.cpp @@ -10,7 +10,7 @@ #if defined(BOOST_NO_CXX14_CONSTEXPR) -BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined") #else diff --git a/test/array_fill_test_cx.cpp b/test/array_fill_test_cx.cpp index c0c8d979..81d4bc17 100644 --- a/test/array_fill_test_cx.cpp +++ b/test/array_fill_test_cx.cpp @@ -10,7 +10,7 @@ #if defined(BOOST_NO_CXX14_CONSTEXPR) -BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined") #else From 0a720268879519b6cc6791a2ee4390e398b36b24 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 06:09:05 +0200 Subject: [PATCH 117/154] Update revision history --- doc/array/changes.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/array/changes.adoc b/doc/array/changes.adoc index 9133d6f0..c98583ce 100644 --- a/doc/array/changes.adoc +++ b/doc/array/changes.adoc @@ -14,3 +14,5 @@ http://www.boost.org/LICENSE_1_0.txt * Converted documentation to AsciiDoc (Christian Mazakas). * Added `noexcept` and `constexpr` as appropriate. +* Marked obsolete functions as deprecated. +* Removed obsolete compiler workarounds. From c95d855018a687244331025d8b4f9bc0946836e4 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 08:09:41 +0200 Subject: [PATCH 118/154] Remove obsolete workaround from `failed_rangecheck` --- include/boost/array.hpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 9d251f74..ca8e14f6 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -303,19 +303,10 @@ namespace boost { BOOST_CXX14_CONSTEXPR void fill (const T& ) {} // check range (may be private because it is static) - static reference failed_rangecheck () { - std::out_of_range e("attempt to access element of an empty array"); - boost::throw_exception(e); -#if defined(BOOST_NO_EXCEPTIONS) || (!defined(BOOST_MSVC) && !defined(__PATHSCALE__)) - // - // We need to return something here to keep - // some compilers happy: however we will never - // actually get here.... - // - static T placeholder; - return placeholder; -#endif - } + static reference failed_rangecheck () + { + boost::throw_exception( std::out_of_range( "attempt to access element of an empty array" ) ); + } }; // comparisons From 43326390d959330fa87b5221fb8e4812f7ba20fb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 08:19:00 +0200 Subject: [PATCH 119/154] Reenable failing test --- test/array_init_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/array_init_test.cpp b/test/array_init_test.cpp index ae40fd36..e2487e7a 100644 --- a/test/array_init_test.cpp +++ b/test/array_init_test.cpp @@ -58,7 +58,7 @@ int main() test2(); test2(); - // test2(); + test2(); #if BOOST_WORKAROUND(BOOST_MSVC, < 1910) || BOOST_WORKAROUND(BOOST_GCC, < 50000) From 89f09e33f1970e7eb56b72b90560e0f2a33d9c96 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 19:21:39 +0200 Subject: [PATCH 120/154] Change array::begin() to return nullptr and make it constexpr. --- include/boost/array.hpp | 12 ++++++------ test/array0.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index ca8e14f6..cc5d55ce 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -207,13 +207,13 @@ namespace boost { typedef std::ptrdiff_t difference_type; // iterator support - iterator begin() BOOST_NOEXCEPT { return iterator( reinterpret_cast< T * >( this ) ); } - const_iterator begin() const BOOST_NOEXCEPT { return const_iterator( reinterpret_cast< const T * >( this ) ); } - const_iterator cbegin() const BOOST_NOEXCEPT { return const_iterator( reinterpret_cast< const T * >( this ) ); } + BOOST_CXX14_CONSTEXPR iterator begin() BOOST_NOEXCEPT { return data(); } + BOOST_CONSTEXPR const_iterator begin() const BOOST_NOEXCEPT { return data(); } + BOOST_CONSTEXPR const_iterator cbegin() const BOOST_NOEXCEPT { return data(); } - iterator end() BOOST_NOEXCEPT { return begin(); } - const_iterator end() const BOOST_NOEXCEPT { return begin(); } - const_iterator cend() const BOOST_NOEXCEPT { return cbegin(); } + BOOST_CXX14_CONSTEXPR iterator end() BOOST_NOEXCEPT { return begin(); } + BOOST_CONSTEXPR const_iterator end() const BOOST_NOEXCEPT { return begin(); } + BOOST_CONSTEXPR const_iterator cend() const BOOST_NOEXCEPT { return cbegin(); } // reverse iterator support typedef std::reverse_iterator reverse_iterator; diff --git a/test/array0.cpp b/test/array0.cpp index e3a62621..d1da316e 100644 --- a/test/array0.cpp +++ b/test/array0.cpp @@ -44,7 +44,12 @@ void RunTests() 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() ); + // BOOST_TEST ( test_case.begin() != const_test_case.begin() ); + // + // TR1 specified that begin() must return a unique value for zero-sized + // arrays. However, this makes constexpr unimplementable, and all standard + // libraries have converged on using nullptr instead (see LWG issue 2157.) + 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! From 3d9f39814c7f806adfb2bb185c0de394b0848da2 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 19:23:41 +0200 Subject: [PATCH 121/154] Re-enable failing tests --- test/array_iterator_test_cx.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/test/array_iterator_test_cx.cpp b/test/array_iterator_test_cx.cpp index 10eef677..1ec91acd 100644 --- a/test/array_iterator_test_cx.cpp +++ b/test/array_iterator_test_cx.cpp @@ -39,20 +39,17 @@ template void test2() { constexpr boost::array a = {}; - // iterator access is not constexpr for boost::array - // it is for std::array, though, so we should change it - STATIC_ASSERT( a.begin() == a.end() ); STATIC_ASSERT( a.cbegin() == a.cend() ); } int main() { - // test1(); + test1(); test1(); test1(); - // test2(); + test2(); } #endif From acef60446ab3bba656e4c4ae59f7ac670fd5a657 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 20:31:53 +0200 Subject: [PATCH 122/154] Update revision history --- doc/array/changes.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/array/changes.adoc b/doc/array/changes.adoc index c98583ce..83aa17ea 100644 --- a/doc/array/changes.adoc +++ b/doc/array/changes.adoc @@ -16,3 +16,5 @@ http://www.boost.org/LICENSE_1_0.txt * Added `noexcept` and `constexpr` as appropriate. * Marked obsolete functions as deprecated. * Removed obsolete compiler workarounds. +* Changed `array::begin()`, `cbegin()`, `end()`, `cend()` to return `nullptr`, enabling `constexpr`. + This matches the behavior of `std::array`. From b14779966508a3aa10a116741bf8deb972078af3 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 20:35:19 +0200 Subject: [PATCH 123/154] Remove local hash_value overload; boost::hash supports array-like types natively. --- include/boost/array.hpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index cc5d55ce..624b26a8 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -395,14 +395,6 @@ namespace boost { return arg.elems; } - template std::size_t hash_range(It, It); - - template - std::size_t hash_value(const array& arr) - { - return boost::hash_range(arr.begin(), arr.end()); - } - template BOOST_CXX14_CONSTEXPR T &get(boost::array &arr) BOOST_NOEXCEPT { BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" ); From 29700ff270ad7d668095bec0e812c5e60be933d8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 21:02:26 +0200 Subject: [PATCH 124/154] Update revision history --- doc/array/changes.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/array/changes.adoc b/doc/array/changes.adoc index 83aa17ea..60fa366d 100644 --- a/doc/array/changes.adoc +++ b/doc/array/changes.adoc @@ -18,3 +18,4 @@ http://www.boost.org/LICENSE_1_0.txt * Removed obsolete compiler workarounds. * Changed `array::begin()`, `cbegin()`, `end()`, `cend()` to return `nullptr`, enabling `constexpr`. This matches the behavior of `std::array`. +* Removed local `hash_value` overload; `boost::hash` supports array-like types natively. From 567ba40840607ad546dc8236f781d78f512ae5ee Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 21:15:39 +0200 Subject: [PATCH 125/154] Add a dummy element to array to enable initialization with = {{}} --- include/boost/array.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 624b26a8..a66de58c 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -195,6 +195,8 @@ namespace boost { template< class T > class array< T, 0 > { + public: + struct {} elems; // enables initialization with = {{}} public: // type definitions From f017dac4357660eb3148f052d2a7e0183ca7ec57 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 21:26:46 +0200 Subject: [PATCH 126/154] Enable failing tests --- test/array_copy_test.cpp | 4 ++-- test/array_init_test.cpp | 4 ++-- test/array_init_test_cx.cpp | 3 ++- test/array_iterator_test.cpp | 4 ++-- test/array_reverse_test.cpp | 4 ++-- test/array_size_test.cpp | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/test/array_copy_test.cpp b/test/array_copy_test.cpp index e94039a4..a4d45a90 100644 --- a/test/array_copy_test.cpp +++ b/test/array_copy_test.cpp @@ -44,11 +44,11 @@ template void test4() int main() { - // test1(); + test1(); test1(); test1(); - // test1(); + test1(); test1(); test1(); diff --git a/test/array_init_test.cpp b/test/array_init_test.cpp index e2487e7a..73b8808f 100644 --- a/test/array_init_test.cpp +++ b/test/array_init_test.cpp @@ -46,11 +46,11 @@ template void test4() int main() { - // test1(); + test1(); test1(); test1(); - // test1(); + test1(); test1(); test1(); diff --git a/test/array_init_test_cx.cpp b/test/array_init_test_cx.cpp index b35fe71d..59fba0f7 100644 --- a/test/array_init_test_cx.cpp +++ b/test/array_init_test_cx.cpp @@ -56,7 +56,8 @@ template void test4() template void test5() { - // constexpr boost::array a = {{}}; + constexpr boost::array a = {{}}; + (void)a; } template void test6() diff --git a/test/array_iterator_test.cpp b/test/array_iterator_test.cpp index 8b75a07a..2e4da0dc 100644 --- a/test/array_iterator_test.cpp +++ b/test/array_iterator_test.cpp @@ -94,11 +94,11 @@ template void test2() int main() { - // test(); + test(); test(); test(); - // test(); + test(); test(); test(); diff --git a/test/array_reverse_test.cpp b/test/array_reverse_test.cpp index 1d556bda..93c598cf 100644 --- a/test/array_reverse_test.cpp +++ b/test/array_reverse_test.cpp @@ -76,11 +76,11 @@ template void test() int main() { - // test(); + test(); test(); test(); - // test(); + test(); test(); test(); diff --git a/test/array_size_test.cpp b/test/array_size_test.cpp index 8780a08c..e8ac4614 100644 --- a/test/array_size_test.cpp +++ b/test/array_size_test.cpp @@ -49,11 +49,11 @@ template void test3() int main() { - // test1(); + test1(); test1(); test1(); - // test1(); + test1(); test1(); test1(); From 527ff0a80d5df948fc3581c0d541b44fb5a30726 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 26 Jan 2025 22:07:42 +0200 Subject: [PATCH 127/154] Update revision history --- doc/array/changes.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/array/changes.adoc b/doc/array/changes.adoc index 60fa366d..fe68750f 100644 --- a/doc/array/changes.adoc +++ b/doc/array/changes.adoc @@ -19,3 +19,4 @@ http://www.boost.org/LICENSE_1_0.txt * Changed `array::begin()`, `cbegin()`, `end()`, `cend()` to return `nullptr`, enabling `constexpr`. This matches the behavior of `std::array`. * Removed local `hash_value` overload; `boost::hash` supports array-like types natively. +* `array` can now be initialized with `= {{}}`. From 9a4010b88b641eda2c822b84f8a7727496813298 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 03:40:19 +0200 Subject: [PATCH 128/154] Add operator<=>, array_thw_test.cpp --- include/boost/array.hpp | 17 ++++++++ test/Jamfile.v2 | 1 + test/array_thw_test.cpp | 87 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 test/array_thw_test.cpp diff --git a/include/boost/array.hpp b/include/boost/array.hpp index a66de58c..995a8888 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -381,6 +381,23 @@ namespace boost { x.swap(y); } +#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L + + template + constexpr auto operator<=> (const array& x, const array& y) + -> decltype( x.elems[ 0 ] <=> y.elems[ 0 ] ) + { + for( std::size_t i = 0; i < N; ++i ) + { + auto r = x.elems[ i ] <=> y.elems[ i ]; + if( r != 0 ) return r; + } + + return 0 <=> 0; // std::strong_ordering::equal + } + +#endif + // undocumented and obsolete template BOOST_DEPRECATED( "please use `elems` instead" ) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 2e0ecb1a..d88ec6b4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -45,6 +45,7 @@ run array_swap_test.cpp ; run array_swap_test2.cpp ; run array_eq_test.cpp ; run array_lt_test.cpp ; +run array_thw_test.cpp ; run array_get_test.cpp ; # C++11 constexpr diff --git a/test/array_thw_test.cpp b/test/array_thw_test.cpp new file mode 100644 index 00000000..fee7ec8e --- /dev/null +++ b/test/array_thw_test.cpp @@ -0,0 +1,87 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if !defined(__cpp_impl_three_way_comparison) + +BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is not defined" ) +int main() {} + +#elif !( __cpp_impl_three_way_comparison >= 201907L ) + +BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is defined to " BOOST_STRINGIZE(__cpp_impl_three_way_comparison) ) +int main() {} + +#else + +template void test() +{ + constexpr auto eq = 0 <=> 0; + constexpr auto lt = 0 <=> 1; + constexpr auto gt = 1 <=> 0; + + { + boost::array const a1 = {}; + boost::array const a2 = {}; + + BOOST_TEST( ( a1 <=> a2 ) == eq ); + } + + { + boost::array a1; + boost::array a2; + + a1.fill( 1 ); + a2.fill( 1 ); + + BOOST_TEST( ( a1 <=> a2 ) == eq ); + } + + for( std::size_t i = 0; i < N; ++i ) + { + boost::array a1; + boost::array a2; + + a1.fill( 1 ); + a2.fill( 1 ); + + a1[ i ] = 0; + + BOOST_TEST( ( a1 <=> a2 ) == lt ); + + { + boost::array const a3 = a1; + boost::array const a4 = a2; + + BOOST_TEST( ( a3 <=> a4 ) == lt ); + } + + a1[ i ] = 2; + + BOOST_TEST( ( a1 <=> a2 ) == gt ); + + { + boost::array const a3 = a1; + boost::array const a4 = a2; + + BOOST_TEST( ( a3 <=> a4 ) == gt ); + } + } +} + +int main() +{ + // test(); + test(); + test(); + + return boost::report_errors(); +} + +#endif From 329e59454f49ded0d90ea54d4c4c7d1503a0f03d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 03:55:13 +0200 Subject: [PATCH 129/154] Add float tests to array_thw_test, as floats use std::partial_ordering --- test/array_thw_test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/array_thw_test.cpp b/test/array_thw_test.cpp index fee7ec8e..3376e363 100644 --- a/test/array_thw_test.cpp +++ b/test/array_thw_test.cpp @@ -81,6 +81,10 @@ int main() test(); test(); + // test(); + test(); + test(); + return boost::report_errors(); } From 68db6ebd2d4813bd5dbf5e9e1c57424fdd003fde Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 03:59:32 +0200 Subject: [PATCH 130/154] Add operator<=> overload for zero-sized arrays --- include/boost/array.hpp | 7 +++++++ test/array_thw_test.cpp | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 995a8888..d1a7a2bb 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -396,6 +396,13 @@ namespace boost { return 0 <=> 0; // std::strong_ordering::equal } + template + constexpr auto operator<=> (const array& x, const array& y) + -> decltype( 0 <=> 0 ) + { + return 0 <=> 0; // std::strong_ordering::equal + } + #endif // undocumented and obsolete diff --git a/test/array_thw_test.cpp b/test/array_thw_test.cpp index 3376e363..8f10368d 100644 --- a/test/array_thw_test.cpp +++ b/test/array_thw_test.cpp @@ -77,11 +77,11 @@ template void test() int main() { - // test(); + test(); test(); test(); - // test(); + test(); test(); test(); From 45de3be80c3edd7ce26202210d1d24206b2ff072 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 04:03:06 +0200 Subject: [PATCH 131/154] Add array_thw_test_cx.cpp --- test/Jamfile.v2 | 1 + test/array_thw_test_cx.cpp | 70 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 test/array_thw_test_cx.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d88ec6b4..eec7d630 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -65,6 +65,7 @@ compile array_access_test_cx2.cpp ; compile array_fill_test_cx.cpp ; compile array_eq_test_cx.cpp ; compile array_lt_test_cx.cpp ; +compile array_thw_test_cx.cpp ; # diff --git a/test/array_thw_test_cx.cpp b/test/array_thw_test_cx.cpp new file mode 100644 index 00000000..6b509385 --- /dev/null +++ b/test/array_thw_test_cx.cpp @@ -0,0 +1,70 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#if !defined(__cpp_impl_three_way_comparison) + +BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is not defined" ) +int main() {} + +#elif !( __cpp_impl_three_way_comparison >= 201907L ) + +BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is defined to " BOOST_STRINGIZE(__cpp_impl_three_way_comparison) ) +int main() {} + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template void test1() +{ + constexpr auto eq = 0 <=> 0; + + constexpr boost::array a1 = {}; + constexpr boost::array a2 = {}; + + STATIC_ASSERT( ( a1 <=> a2 ) == eq ); +} + +template void test2() +{ + constexpr auto eq = 0 <=> 0; + constexpr auto lt = 0 <=> 1; + constexpr auto gt = 1 <=> 0; + + { + constexpr boost::array a1 = {{ 1, 2, 3, 4 }}; + constexpr boost::array a2 = {{ 1, 2, 3, 4 }}; + + STATIC_ASSERT( ( a1 <=> a2 ) == eq ); + } + { + constexpr boost::array a1 = {{ 1, 2, 3, 4 }}; + constexpr boost::array a2 = {{ 1, 2, 3, 5 }}; + + STATIC_ASSERT( ( a1 <=> a2 ) == lt ); + } + { + constexpr boost::array a1 = {{ 1, 2, 3, 4 }}; + constexpr boost::array a2 = {{ 1, 2, 3, 2 }}; + + STATIC_ASSERT( ( a1 <=> a2 ) == gt ); + } +} + +int main() +{ + test1(); + test1(); + test1(); + + test2(); +} + +#endif From 047ba01807c38891355bf935b71878e3abe177cd Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 17:16:50 +0200 Subject: [PATCH 132/154] Update documentation --- doc/array/reference.adoc | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/doc/array/reference.adoc b/doc/array/reference.adoc index e2265de5..114b27a8 100644 --- a/doc/array/reference.adoc +++ b/doc/array/reference.adoc @@ -35,6 +35,9 @@ namespace boost { template constexpr bool operator>=(const array&, const array&); + template + constexpr auto operator<=>(const array&, const array&); + template constexpr T& get(array&) noexcept; template @@ -136,7 +139,7 @@ public: template array& operator=(const array& other); ``` [horizontal] -Effects: :: `std::copy(rhs.begin(), rhs.end(), begin())`. +Effects: :: For each `i` in `[0..N)`, performs `elems[i] = other.elems[i];`. --- @@ -233,7 +236,7 @@ constexpr const_reference operator[](size_type i) const; [horizontal] Requires: :: `i < N`. Returns: :: `elems[i]`. -Throws: :: nothing. +Throws: :: Nothing. --- @@ -254,7 +257,7 @@ constexpr const_reference front() const; [horizontal] Requires: :: `N > 0`. Returns: :: `elems[0]`. -Throws: :: nothing. +Throws: :: Nothing. --- @@ -265,7 +268,7 @@ constexpr const_reference back() const; [horizontal] Requires: :: `N > 0`. Returns: :: `elems[N-1]`. -Throws: :: nothing. +Throws: :: Nothing. --- @@ -302,7 +305,7 @@ Complexity: :: linear in `N`. void fill(const T& value); ``` [horizontal] -Effects: :: for each `i` in `[0..N)`, performs `elems[i] = value;`. +Effects: :: For each `i` in `[0..N)`, performs `elems[i] = value;`. --- @@ -382,6 +385,17 @@ Returns: :: `!(x < y)`. --- +``` +template + constexpr auto operator<=>(const array& x, const array& y) + -> decltype(x[0] <=> y[0]); +``` +[horizontal] +Effects: :: For each `i` in `[0..N)`, if `(x[i] \<\=> y[i]) != 0`, returns `x[i] \<\=> y[i]`. Otherwise, returns `std::strong_ordering::equal`, converted to the return type. +Remarks: :: When `N` is 0, the return type is `std::strong_ordering` and the return value is `std::strong_ordering::equal`. + +--- + ### Specializations ``` From 07a14f33efcd4ea011783475a3c4674bd4a243f0 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 17:19:06 +0200 Subject: [PATCH 133/154] Update revision history --- doc/array/changes.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/array/changes.adoc b/doc/array/changes.adoc index fe68750f..8992e331 100644 --- a/doc/array/changes.adoc +++ b/doc/array/changes.adoc @@ -20,3 +20,4 @@ http://www.boost.org/LICENSE_1_0.txt This matches the behavior of `std::array`. * Removed local `hash_value` overload; `boost::hash` supports array-like types natively. * `array` can now be initialized with `= {{}}`. +* Added `operator\<\=>`. From 49e2a46c3a9f6b30396adfd629321d748ef086a2 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 17:41:50 +0200 Subject: [PATCH 134/154] Enable warnings=extra, warnings-as-errors=on in test suite --- include/boost/array.hpp | 6 +++--- test/Jamfile.v2 | 10 ++++++++++ test/array5.cpp | 2 ++ test/array6.cpp | 2 ++ test/array7.cpp | 2 ++ test/array_assign_test.cpp | 5 +++-- test/array_c_array_test.cpp | 5 +++-- test/array_size_test.cpp | 4 ++++ 8 files changed, 29 insertions(+), 7 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index d1a7a2bb..4e62c55b 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -326,7 +326,7 @@ namespace boost { #if BOOST_WORKAROUND(BOOST_GCC, < 90000) template - BOOST_CXX14_CONSTEXPR bool operator== (const array& x, const array& y) + BOOST_CXX14_CONSTEXPR bool operator== (const array& /*x*/, const array& /*y*/) { return true; } @@ -353,7 +353,7 @@ namespace boost { #if BOOST_WORKAROUND(BOOST_GCC, < 90000) template - BOOST_CXX14_CONSTEXPR bool operator< (const array& x, const array& y) + BOOST_CXX14_CONSTEXPR bool operator< (const array& /*x*/, const array& /*y*/) { return false; } @@ -397,7 +397,7 @@ namespace boost { } template - constexpr auto operator<=> (const array& x, const array& y) + constexpr auto operator<=> (const array& /*x*/, const array& /*y*/) -> decltype( 0 <=> 0 ) { return 0 <=> 0; // std::strong_ordering::equal diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index eec7d630..282764a9 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -7,6 +7,16 @@ import testing ; import-search /boost/config/checks ; import config : requires ; +project + : requirements + + extra + + msvc:on + clang:on + gcc:on + ; + # run array0.cpp ; diff --git a/test/array5.cpp b/test/array5.cpp index 23156b9c..23352a7f 100644 --- a/test/array5.cpp +++ b/test/array5.cpp @@ -5,6 +5,8 @@ * http://www.boost.org/LICENSE_1_0.txt) */ +#define BOOST_ALLOW_DEPRECATED_SYMBOLS // assign + #include #include diff --git a/test/array6.cpp b/test/array6.cpp index d2cca910..3f3f5b01 100644 --- a/test/array6.cpp +++ b/test/array6.cpp @@ -5,6 +5,8 @@ * http://www.boost.org/LICENSE_1_0.txt) */ +#define BOOST_ALLOW_DEPRECATED_SYMBOLS // get_c_array + #include #include #include diff --git a/test/array7.cpp b/test/array7.cpp index 567b2e61..1e70108d 100644 --- a/test/array7.cpp +++ b/test/array7.cpp @@ -5,6 +5,8 @@ * http://www.boost.org/LICENSE_1_0.txt) */ +#define BOOST_ALLOW_DEPRECATED_SYMBOLS // std::get + #include #include #include diff --git a/test/array_assign_test.cpp b/test/array_assign_test.cpp index 91c9b161..b9255caf 100644 --- a/test/array_assign_test.cpp +++ b/test/array_assign_test.cpp @@ -2,12 +2,13 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt) +#define BOOST_ALLOW_DEPRECATED_SYMBOLS + #include #include #include -// assign is a nonstandard equivalent of fill -// it probably needs to be deprecated and removed +// assign is a deprecated nonstandard equivalent of fill template void test() { diff --git a/test/array_c_array_test.cpp b/test/array_c_array_test.cpp index b65d4449..b89e25fc 100644 --- a/test/array_c_array_test.cpp +++ b/test/array_c_array_test.cpp @@ -2,14 +2,15 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt) +#define BOOST_ALLOW_DEPRECATED_SYMBOLS + #include #include #include #include #include -// c_array and get_c_array are nonstandard extensions -// probably need to be deprecated and removed +// c_array and get_c_array are deprecated nonstandard extensions template void test() { diff --git a/test/array_size_test.cpp b/test/array_size_test.cpp index e8ac4614..50aa55e5 100644 --- a/test/array_size_test.cpp +++ b/test/array_size_test.cpp @@ -15,6 +15,8 @@ template void test1() BOOST_TEST_EQ( a.size(), N ); BOOST_TEST_EQ( a.empty(), N == 0 ); BOOST_TEST_EQ( a.max_size(), N ); + + (void)a; // msvc-12.0 } { @@ -23,6 +25,8 @@ template void test1() BOOST_TEST_EQ( a.size(), N ); BOOST_TEST_EQ( a.empty(), N == 0 ); BOOST_TEST_EQ( a.max_size(), N ); + + (void)a; // msvc-12.0 } } From 75db85d1e992b182deaeceb6da49a867cf35c6d0 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 18:23:43 +0200 Subject: [PATCH 135/154] Suppress MSVC unreachable code warnings --- include/boost/array.hpp | 7 ++++--- test/array_assign_test.cpp | 6 +++++- test/array_eq_test.cpp | 4 ++++ test/array_fill_test.cpp | 4 ++++ test/array_init_test.cpp | 4 ++++ test/array_lt_test.cpp | 4 ++++ test/array_swap_test.cpp | 4 ++++ test/array_swap_test2.cpp | 4 ++++ 8 files changed, 33 insertions(+), 4 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 4e62c55b..12a2e9eb 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -37,9 +37,10 @@ #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) # pragma warning(push) -# pragma warning(disable:4510) // boost::array' : default constructor could not be generated -# pragma warning(disable:4512) // boost::array' : assignment operator could not be generated -# pragma warning(disable:4610) // class 'boost::array' can never be instantiated - user defined constructor required +# pragma warning(disable: 4510) // boost::array' : default constructor could not be generated +# pragma warning(disable: 4512) // boost::array' : assignment operator could not be generated +# pragma warning(disable: 4610) // class 'boost::array' can never be instantiated - user defined constructor required +# pragma warning(disable: 4702) // unreachable code #endif #include diff --git a/test/array_assign_test.cpp b/test/array_assign_test.cpp index b9255caf..b41d72aa 100644 --- a/test/array_assign_test.cpp +++ b/test/array_assign_test.cpp @@ -4,11 +4,15 @@ #define BOOST_ALLOW_DEPRECATED_SYMBOLS +// assign is a deprecated nonstandard equivalent of fill + #include #include #include -// assign is a deprecated nonstandard equivalent of fill +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif template void test() { diff --git a/test/array_eq_test.cpp b/test/array_eq_test.cpp index c0ba3fa4..1dbe9e74 100644 --- a/test/array_eq_test.cpp +++ b/test/array_eq_test.cpp @@ -6,6 +6,10 @@ #include #include +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif + template void test() { { diff --git a/test/array_fill_test.cpp b/test/array_fill_test.cpp index 17ca90fd..0ea3da4e 100644 --- a/test/array_fill_test.cpp +++ b/test/array_fill_test.cpp @@ -6,6 +6,10 @@ #include #include +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif + template void test() { boost::array a = {}; diff --git a/test/array_init_test.cpp b/test/array_init_test.cpp index 73b8808f..676e9d0a 100644 --- a/test/array_init_test.cpp +++ b/test/array_init_test.cpp @@ -8,6 +8,10 @@ #include #include +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif + template void test1() { boost::array a = {{}}; diff --git a/test/array_lt_test.cpp b/test/array_lt_test.cpp index d2ec7f6d..06f3ec5b 100644 --- a/test/array_lt_test.cpp +++ b/test/array_lt_test.cpp @@ -6,6 +6,10 @@ #include #include +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif + template void test() { { diff --git a/test/array_swap_test.cpp b/test/array_swap_test.cpp index fb417980..f7b178a2 100644 --- a/test/array_swap_test.cpp +++ b/test/array_swap_test.cpp @@ -6,6 +6,10 @@ #include #include +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif + template void test() { boost::array a1 = {}; diff --git a/test/array_swap_test2.cpp b/test/array_swap_test2.cpp index 6ad173cf..e9bd1b4a 100644 --- a/test/array_swap_test2.cpp +++ b/test/array_swap_test2.cpp @@ -6,6 +6,10 @@ #include #include +#if defined(_MSC_VER) +# pragma warning(disable: 4702) // unreachable code +#endif + template void test() { boost::array a1 = {}; From 771750f7e1ab62739ef76d813cf30c0bf7e14c01 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 18:26:10 +0200 Subject: [PATCH 136/154] Supress GCC and Clang warnings --- test/Jamfile.v2 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 282764a9..de913509 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -15,6 +15,28 @@ project msvc:on clang:on gcc:on + + gcc-4.6:-Wno-missing-braces + gcc-4.7:-Wno-missing-braces + + gcc-4.6:-Wno-missing-field-initializers + gcc-4.7:-Wno-missing-field-initializers + gcc-4.8:-Wno-missing-field-initializers + gcc-4.9:-Wno-missing-field-initializers + + gcc-4.6:-Wno-type-limits + gcc-4.7:-Wno-type-limits + gcc-10:-Wno-type-limits + + clang:-Wno-unnamed-type-template-args + + clang-3.5:-Wno-missing-braces + clang-3.6:-Wno-missing-braces + clang-3.7:-Wno-missing-braces + clang-3.8:-Wno-missing-braces + clang-3.9:-Wno-missing-braces + clang-4:-Wno-missing-braces + clang-5:-Wno-missing-braces ; # From 59e9940d5b824c315a80d2c3446ca810743d4fd9 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 19:38:14 +0200 Subject: [PATCH 137/154] Suppress false -Warray-bounds positive with -fsanitize=undefined --- test/array6.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/array6.cpp b/test/array6.cpp index 3f3f5b01..65b8d477 100644 --- a/test/array6.cpp +++ b/test/array6.cpp @@ -7,12 +7,18 @@ #define BOOST_ALLOW_DEPRECATED_SYMBOLS // get_c_array +#include +#include +#include #include #include -#include #include -#include +#if defined(BOOST_GCC) && BOOST_GCC / 10000 == 13 +// false -Warray-bounds positive when using -fsanitize=undefined +// restricted to GCC 13 because that's what is tested on Drone +# pragma GCC diagnostic ignored "-Warray-bounds" +#endif namespace { template< class T > From 61bbcbf341666ebd00168ab39c2ea07b9f153e24 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 19:41:32 +0200 Subject: [PATCH 138/154] Disable warnings for compile-fail tests --- test/Jamfile.v2 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index de913509..eaef21dc 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -52,8 +52,10 @@ run array7.cpp ; compile array_constexpr.cpp ; -compile-fail array_getfail1.cpp ; -compile-fail array_getfail2.cpp ; +compile-fail array_getfail1.cpp + : off ; +compile-fail array_getfail2.cpp + : off ; run array_hash.cpp : : : [ requires cxx11_noexcept ] ; From 703ad46b818719dc07d1ed8f3e041f6f57a7df7d Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 21:18:15 +0200 Subject: [PATCH 139/154] Fix test/Jamfile project requirements --- test/Jamfile.v2 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 845875bc..72437657 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -10,6 +10,9 @@ import config : requires ; project : requirements + /boost/array//boost_array + /boost/core//boost_core + extra msvc:on @@ -41,8 +44,6 @@ project # -project : requirements /boost/array//boost_array ; - run array0.cpp ; run array1.cpp ; run array2.cpp ; From b2f6f0ca65a9a9c95395da2c125d5f59a1bb4a24 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 21:21:34 +0200 Subject: [PATCH 140/154] Update build.jam --- build.jam | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/build.jam b/build.jam index b927d267..7376d93b 100644 --- a/build.jam +++ b/build.jam @@ -1,24 +1,21 @@ -# Copyright RenĂ© Ferdinand Rivera Morell 2023-2024 +# Copyright 2023-2024 RenĂ© Ferdinand Rivera Morell +# Copyright 2024 Peter Dimov # 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) +# https://www.boost.org/LICENSE_1_0.txt require-b2 5.2 ; constant boost_dependencies : /boost/assert//boost_assert /boost/config//boost_config - /boost/core//boost_core /boost/static_assert//boost_static_assert - /boost/throw_exception//boost_throw_exception ; - -project /boost/array - : common-requirements - include + /boost/throw_exception//boost_throw_exception ; +project /boost/array ; + explicit - [ alias boost_array : : : : $(boost_dependencies) ] + [ alias boost_array : : : : include $(boost_dependencies) ] [ alias all : boost_array test ] ; From 8991751e3b6bfc9bb6c653523b6016980787a657 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 27 Jan 2025 21:22:01 +0200 Subject: [PATCH 141/154] Regenerate CMakeLists.txt --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6727882e..7684b1d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,6 @@ target_link_libraries(boost_array INTERFACE Boost::assert Boost::config - Boost::core Boost::static_assert Boost::throw_exception ) From 37a4833e262ea34cddbab9012ebc077b996f4581 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 29 Jan 2025 03:14:12 +0200 Subject: [PATCH 142/154] Add the rest of the Clangs to Drone --- .drone.jsonnet | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/.drone.jsonnet b/.drone.jsonnet index 8c214e88..b65d8864 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -235,6 +235,76 @@ local windows_pipeline(name, image, environment, arch = "amd64") = "clang-3.8", ), + linux_pipeline( + "Linux 18.04 Clang 3.9", + "cppalliance/droneubuntu1804:1", + { TOOLSET: 'clang', COMPILER: 'clang++-3.9', CXXSTD: '03,11,14' }, + "clang-3.9", + ), + + linux_pipeline( + "Linux 18.04 Clang 4.0", + "cppalliance/droneubuntu1804:1", + { TOOLSET: 'clang', COMPILER: 'clang++-4.0', CXXSTD: '03,11,14' }, + "clang-4.0", + ), + + linux_pipeline( + "Linux 18.04 Clang 5.0", + "cppalliance/droneubuntu1804:1", + { TOOLSET: 'clang', COMPILER: 'clang++-5.0', CXXSTD: '03,11,14,1z' }, + "clang-5.0", + ), + + linux_pipeline( + "Linux 18.04 Clang 6.0", + "cppalliance/droneubuntu1804:1", + { TOOLSET: 'clang', COMPILER: 'clang++-6.0', CXXSTD: '03,11,14,17' }, + "clang-6.0", + ), + + linux_pipeline( + "Linux 20.04 Clang 7", + "cppalliance/droneubuntu2004:1", + { TOOLSET: 'clang', COMPILER: 'clang++-7', CXXSTD: '03,11,14,17' }, + "clang-7", + ), + + linux_pipeline( + "Linux 20.04 Clang 8", + "cppalliance/droneubuntu2004:1", + { TOOLSET: 'clang', COMPILER: 'clang++-8', CXXSTD: '03,11,14,17' }, + "clang-8", + ), + + linux_pipeline( + "Linux 20.04 Clang 9", + "cppalliance/droneubuntu2004:1", + { TOOLSET: 'clang', COMPILER: 'clang++-9', CXXSTD: '03,11,14,17,2a' }, + "clang-9", + ), + + linux_pipeline( + "Linux 20.04 Clang 10", + "cppalliance/droneubuntu2004:1", + { TOOLSET: 'clang', COMPILER: 'clang++-10', CXXSTD: '03,11,14,17,2a' }, + "clang-10", + ), + + linux_pipeline( + "Linux 20.04 Clang 11", + "cppalliance/droneubuntu2004:1", + { TOOLSET: 'clang', COMPILER: 'clang++-11', CXXSTD: '03,11,14,17,2a' }, + "clang-11", + ), + + linux_pipeline( + "Linux 20.04 Clang 12", + "cppalliance/droneubuntu2004:1", + { TOOLSET: 'clang', COMPILER: 'clang++-12', CXXSTD: '03,11,14,17,2a' }, + "clang-12", + ), + linux_pipeline( "Linux 22.04 Clang 13", "cppalliance/droneubuntu2204:1", From 84d0f84c9bb386aa0595f9abdc2baa3494603d9b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 29 Jan 2025 04:03:41 +0200 Subject: [PATCH 143/154] Check for the existence of , include it, use it; 0 <=> 0 doesn't work without it anyway. --- include/boost/array.hpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 12a2e9eb..601fee86 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -51,6 +51,12 @@ #include #include +#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L +# if __has_include() +# include +# endif +#endif + namespace boost { template @@ -383,6 +389,7 @@ namespace boost { } #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L +# if __has_include() template constexpr auto operator<=> (const array& x, const array& y) @@ -394,16 +401,17 @@ namespace boost { if( r != 0 ) return r; } - return 0 <=> 0; // std::strong_ordering::equal + return std::strong_ordering::equal; } template constexpr auto operator<=> (const array& /*x*/, const array& /*y*/) - -> decltype( 0 <=> 0 ) + -> std::strong_ordering { - return 0 <=> 0; // std::strong_ordering::equal + return std::strong_ordering::equal; } +# endif #endif // undocumented and obsolete From 9b508e3ad2eaa3787471dd0a56a44662ccc0b7b8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 29 Jan 2025 04:15:17 +0200 Subject: [PATCH 144/154] Disable <=> tests when isn't available --- test/array_thw_test.cpp | 11 +++++++++++ test/array_thw_test_cx.cpp | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/test/array_thw_test.cpp b/test/array_thw_test.cpp index 8f10368d..dca9d8c7 100644 --- a/test/array_thw_test.cpp +++ b/test/array_thw_test.cpp @@ -8,6 +8,12 @@ #include #include +#if defined(__has_include) +# if __has_include() +# define HAS_COMPARE +# endif +#endif + #if !defined(__cpp_impl_three_way_comparison) BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is not defined" ) @@ -18,6 +24,11 @@ int main() {} BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is defined to " BOOST_STRINGIZE(__cpp_impl_three_way_comparison) ) int main() {} +#elif !defined(HAS_COMPARE) + +BOOST_PRAGMA_MESSAGE( "Test skipped because is not available" ) +int main() {} + #else template void test() diff --git a/test/array_thw_test_cx.cpp b/test/array_thw_test_cx.cpp index 6b509385..dde5f654 100644 --- a/test/array_thw_test_cx.cpp +++ b/test/array_thw_test_cx.cpp @@ -8,6 +8,12 @@ #include #include +#if defined(__has_include) +# if __has_include() +# define HAS_COMPARE +# endif +#endif + #if !defined(__cpp_impl_three_way_comparison) BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is not defined" ) @@ -18,6 +24,11 @@ int main() {} BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is defined to " BOOST_STRINGIZE(__cpp_impl_three_way_comparison) ) int main() {} +#elif !defined(HAS_COMPARE) + +BOOST_PRAGMA_MESSAGE( "Test skipped because is not available" ) +int main() {} + #else #define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) From 37289c5d92aa4ef9b4203e49746ddd733e984ab1 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 23 Feb 2025 20:45:50 +0200 Subject: [PATCH 145/154] Add to_array --- include/boost/array.hpp | 65 ++++++++++++++++++++---- test/Jamfile.v2 | 1 + test/to_array_test.cpp | 107 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+), 10 deletions(-) create mode 100644 test/to_array_test.cpp diff --git a/include/boost/array.hpp b/include/boost/array.hpp index 601fee86..bea6f981 100644 --- a/include/boost/array.hpp +++ b/include/boost/array.hpp @@ -430,17 +430,62 @@ namespace boost { return arg.elems; } - template - BOOST_CXX14_CONSTEXPR T &get(boost::array &arr) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" ); - return arr[Idx]; - } + template + BOOST_CXX14_CONSTEXPR T &get(boost::array &arr) BOOST_NOEXCEPT + { + BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" ); + return arr[Idx]; + } - template - BOOST_CONSTEXPR const T &get(const boost::array &arr) BOOST_NOEXCEPT { - BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(const boost::array &) index out of range" ); - return arr[Idx]; - } + template + BOOST_CONSTEXPR const T &get(const boost::array &arr) BOOST_NOEXCEPT + { + BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(const boost::array &) index out of range" ); + return arr[Idx]; + } + + template + BOOST_CXX14_CONSTEXPR array to_array( T const (&a)[ N ] ) + { + array r = {}; + + for( std::size_t i = 0; i < N; ++i ) + { + r[ i ] = a[ i ]; + } + + return r; + } + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + + template + BOOST_CXX14_CONSTEXPR array to_array( T (&&a)[ N ] ) + { + array r = {}; + + for( std::size_t i = 0; i < N; ++i ) + { + r[ i ] = std::move( a[ i ] ); + } + + return r; + } + + template + BOOST_CXX14_CONSTEXPR array to_array( T const (&&a)[ N ] ) + { + array r = {}; + + for( std::size_t i = 0; i < N; ++i ) + { + r[ i ] = a[ i ]; + } + + return r; + } + +#endif } /* namespace boost */ diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 72437657..02c6464f 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -84,6 +84,7 @@ run array_eq_test.cpp ; run array_lt_test.cpp ; run array_thw_test.cpp ; run array_get_test.cpp ; +run to_array_test.cpp ; # C++11 constexpr diff --git a/test/to_array_test.cpp b/test/to_array_test.cpp new file mode 100644 index 00000000..6d4cd831 --- /dev/null +++ b/test/to_array_test.cpp @@ -0,0 +1,107 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include + +boost::array f1() +{ + boost::array r = {{ 1, 2, 3 }}; + return r; +} + +boost::array const f2() +{ + boost::array r = {{ 1, 2, 3 }}; + return r; +} + +int main() +{ + { + int a[] = { 1, 2, 3 }; + + boost::array b = boost::to_array( a ); + + BOOST_TEST_EQ( b[0], 1 ); + BOOST_TEST_EQ( b[1], 2 ); + BOOST_TEST_EQ( b[2], 3 ); + } + + { + int const a[] = { 1, 2, 3 }; + + boost::array b = boost::to_array( a ); + + BOOST_TEST_EQ( b[0], 1 ); + BOOST_TEST_EQ( b[1], 2 ); + BOOST_TEST_EQ( b[2], 3 ); + } + + { + boost::array b = boost::to_array( f1().elems ); + + BOOST_TEST_EQ( b[0], 1 ); + BOOST_TEST_EQ( b[1], 2 ); + BOOST_TEST_EQ( b[2], 3 ); + } + + { + boost::array b = boost::to_array( f2().elems ); + + BOOST_TEST_EQ( b[0], 1 ); + BOOST_TEST_EQ( b[1], 2 ); + BOOST_TEST_EQ( b[2], 3 ); + } + +#if BOOST_CXX_VERSION >= 201103L + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1910) + { + int a[] = { 1, 2, 3 }; + + boost::array b = boost::to_array( std::move( a ) ); + + BOOST_TEST_EQ( b[0], 1 ); + BOOST_TEST_EQ( b[1], 2 ); + BOOST_TEST_EQ( b[2], 3 ); + } + + { + int const a[] = { 1, 2, 3 }; + + boost::array b = boost::to_array( std::move( a ) ); + + BOOST_TEST_EQ( b[0], 1 ); + BOOST_TEST_EQ( b[1], 2 ); + BOOST_TEST_EQ( b[2], 3 ); + } +#endif + + { + boost::array b = boost::to_array({ 1, 2, 3 }); + + BOOST_TEST_EQ( b[0], 1 ); + BOOST_TEST_EQ( b[1], 2 ); + BOOST_TEST_EQ( b[2], 3 ); + } + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1920) + { + std::unique_ptr a[] = { {}, {}, {} }; + + boost::array, 3> b = boost::to_array( std::move( a ) ); + + (void)b; + } +#endif + +#endif + + return boost::report_errors(); +} From ffbced7a17b8c915e21e6cd575b3620bec8631f0 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 23 Feb 2025 20:54:43 +0200 Subject: [PATCH 146/154] Disable initializer list test for GCC < 4.9 and Clang < 3.8 --- test/to_array_test.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/to_array_test.cpp b/test/to_array_test.cpp index 6d4cd831..3bfb726b 100644 --- a/test/to_array_test.cpp +++ b/test/to_array_test.cpp @@ -83,6 +83,7 @@ int main() } #endif +#if !BOOST_WORKAROUND(BOOST_GCC, < 40900) && !BOOST_WORKAROUND(BOOST_CLANG_VERSION, < 30800) { boost::array b = boost::to_array({ 1, 2, 3 }); @@ -90,6 +91,7 @@ int main() BOOST_TEST_EQ( b[1], 2 ); BOOST_TEST_EQ( b[2], 3 ); } +#endif #if !BOOST_WORKAROUND(BOOST_MSVC, < 1920) { From e97dc5386831636e2a31024281614a071cae1984 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 23 Feb 2025 20:59:49 +0200 Subject: [PATCH 147/154] Add to_array_test_cx.cpp --- test/Jamfile.v2 | 1 + test/to_array_test_cx.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 test/to_array_test_cx.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 02c6464f..58f60aaf 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -104,6 +104,7 @@ compile array_fill_test_cx.cpp ; compile array_eq_test_cx.cpp ; compile array_lt_test_cx.cpp ; compile array_thw_test_cx.cpp ; +compile to_array_test_cx.cpp ; # diff --git a/test/to_array_test_cx.cpp b/test/to_array_test_cx.cpp new file mode 100644 index 00000000..e7f32c73 --- /dev/null +++ b/test/to_array_test_cx.cpp @@ -0,0 +1,32 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX14_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +int main() +{ + { + constexpr int a[] = { 1, 2, 3, 4 }; + constexpr boost::array b = boost::to_array( a ); + + STATIC_ASSERT( b[0] == 1 ); + STATIC_ASSERT( b[1] == 2 ); + STATIC_ASSERT( b[2] == 3 ); + STATIC_ASSERT( b[3] == 4 ); + } +} + +#endif From ec61272c1f16ee8a845f24b00a3bf2d8a7b15dbb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 23 Feb 2025 21:04:28 +0200 Subject: [PATCH 148/154] Remove stray parentheses --- test/array_access_test.cpp | 2 +- test/array_access_test_cx.cpp | 2 +- test/array_access_test_cx2.cpp | 2 +- test/array_assign_test.cpp | 2 +- test/array_assign_test_cx.cpp | 2 +- test/array_c_array_test.cpp | 2 +- test/array_convert_test.cpp | 2 +- test/array_copy_test.cpp | 2 +- test/array_copy_test_cx.cpp | 2 +- test/array_data_test.cpp | 2 +- test/array_data_test_cx.cpp | 2 +- test/array_elems_test.cpp | 2 +- test/array_eq_test.cpp | 2 +- test/array_eq_test_cx.cpp | 2 +- test/array_fill_test.cpp | 2 +- test/array_fill_test_cx.cpp | 2 +- test/array_get_test.cpp | 2 +- test/array_get_test_cx.cpp | 2 +- test/array_init_test.cpp | 2 +- test/array_init_test_cx.cpp | 2 +- test/array_iterator_test.cpp | 2 +- test/array_iterator_test_cx.cpp | 2 +- test/array_lt_test.cpp | 2 +- test/array_lt_test_cx.cpp | 2 +- test/array_reverse_test.cpp | 2 +- test/array_size_test.cpp | 2 +- test/array_size_test_cx.cpp | 2 +- test/array_swap_test.cpp | 2 +- test/array_swap_test2.cpp | 2 +- test/array_thw_test.cpp | 2 +- test/array_thw_test_cx.cpp | 2 +- test/array_typedef_test.cpp | 2 +- test/quick.cpp | 2 +- test/to_array_test.cpp | 2 +- 34 files changed, 34 insertions(+), 34 deletions(-) diff --git a/test/array_access_test.cpp b/test/array_access_test.cpp index 44be92e0..b1ec6c8d 100644 --- a/test/array_access_test.cpp +++ b/test/array_access_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #define BOOST_ENABLE_ASSERT_HANDLER diff --git a/test/array_access_test_cx.cpp b/test/array_access_test_cx.cpp index 0018d95c..507cd288 100644 --- a/test/array_access_test_cx.cpp +++ b/test/array_access_test_cx.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_access_test_cx2.cpp b/test/array_access_test_cx2.cpp index 9e00fe0f..18dbbf4d 100644 --- a/test/array_access_test_cx2.cpp +++ b/test/array_access_test_cx2.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_assign_test.cpp b/test/array_assign_test.cpp index b41d72aa..44fa9473 100644 --- a/test/array_assign_test.cpp +++ b/test/array_assign_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #define BOOST_ALLOW_DEPRECATED_SYMBOLS diff --git a/test/array_assign_test_cx.cpp b/test/array_assign_test_cx.cpp index ce8031cd..d767636c 100644 --- a/test/array_assign_test_cx.cpp +++ b/test/array_assign_test_cx.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_c_array_test.cpp b/test/array_c_array_test.cpp index b89e25fc..89751d14 100644 --- a/test/array_c_array_test.cpp +++ b/test/array_c_array_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #define BOOST_ALLOW_DEPRECATED_SYMBOLS diff --git a/test/array_convert_test.cpp b/test/array_convert_test.cpp index aa1e9c78..7060ec8c 100644 --- a/test/array_convert_test.cpp +++ b/test/array_convert_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_copy_test.cpp b/test/array_copy_test.cpp index a4d45a90..5701f5b1 100644 --- a/test/array_copy_test.cpp +++ b/test/array_copy_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_copy_test_cx.cpp b/test/array_copy_test_cx.cpp index 9a4ab56e..a22c3774 100644 --- a/test/array_copy_test_cx.cpp +++ b/test/array_copy_test_cx.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_data_test.cpp b/test/array_data_test.cpp index d27fec1b..432139aa 100644 --- a/test/array_data_test.cpp +++ b/test/array_data_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_data_test_cx.cpp b/test/array_data_test_cx.cpp index a9f8322c..f567b39a 100644 --- a/test/array_data_test_cx.cpp +++ b/test/array_data_test_cx.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_elems_test.cpp b/test/array_elems_test.cpp index 9506cbfc..0773882c 100644 --- a/test/array_elems_test.cpp +++ b/test/array_elems_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_eq_test.cpp b/test/array_eq_test.cpp index 1dbe9e74..e85ad317 100644 --- a/test/array_eq_test.cpp +++ b/test/array_eq_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_eq_test_cx.cpp b/test/array_eq_test_cx.cpp index 202bc258..6fe7ea19 100644 --- a/test/array_eq_test_cx.cpp +++ b/test/array_eq_test_cx.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_fill_test.cpp b/test/array_fill_test.cpp index 0ea3da4e..f8fc92dd 100644 --- a/test/array_fill_test.cpp +++ b/test/array_fill_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_fill_test_cx.cpp b/test/array_fill_test_cx.cpp index 81d4bc17..9fd4a8a7 100644 --- a/test/array_fill_test_cx.cpp +++ b/test/array_fill_test_cx.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_get_test.cpp b/test/array_get_test.cpp index 32faa944..bc45669b 100644 --- a/test/array_get_test.cpp +++ b/test/array_get_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_get_test_cx.cpp b/test/array_get_test_cx.cpp index eb7f1174..693afa17 100644 --- a/test/array_get_test_cx.cpp +++ b/test/array_get_test_cx.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_init_test.cpp b/test/array_init_test.cpp index 676e9d0a..33889457 100644 --- a/test/array_init_test.cpp +++ b/test/array_init_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_init_test_cx.cpp b/test/array_init_test_cx.cpp index 59fba0f7..1a8cfd23 100644 --- a/test/array_init_test_cx.cpp +++ b/test/array_init_test_cx.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_iterator_test.cpp b/test/array_iterator_test.cpp index 2e4da0dc..a88dd281 100644 --- a/test/array_iterator_test.cpp +++ b/test/array_iterator_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_iterator_test_cx.cpp b/test/array_iterator_test_cx.cpp index 1ec91acd..92598987 100644 --- a/test/array_iterator_test_cx.cpp +++ b/test/array_iterator_test_cx.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_lt_test.cpp b/test/array_lt_test.cpp index 06f3ec5b..bed29f6d 100644 --- a/test/array_lt_test.cpp +++ b/test/array_lt_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_lt_test_cx.cpp b/test/array_lt_test_cx.cpp index d01c9e45..fff2e950 100644 --- a/test/array_lt_test_cx.cpp +++ b/test/array_lt_test_cx.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_reverse_test.cpp b/test/array_reverse_test.cpp index 93c598cf..0f3fcea2 100644 --- a/test/array_reverse_test.cpp +++ b/test/array_reverse_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_size_test.cpp b/test/array_size_test.cpp index 50aa55e5..a4c493dd 100644 --- a/test/array_size_test.cpp +++ b/test/array_size_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_size_test_cx.cpp b/test/array_size_test_cx.cpp index bfa4f40f..bc3d6a5c 100644 --- a/test/array_size_test_cx.cpp +++ b/test/array_size_test_cx.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_swap_test.cpp b/test/array_swap_test.cpp index f7b178a2..db4733a2 100644 --- a/test/array_swap_test.cpp +++ b/test/array_swap_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_swap_test2.cpp b/test/array_swap_test2.cpp index e9bd1b4a..5007f561 100644 --- a/test/array_swap_test2.cpp +++ b/test/array_swap_test2.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_thw_test.cpp b/test/array_thw_test.cpp index dca9d8c7..357c1eae 100644 --- a/test/array_thw_test.cpp +++ b/test/array_thw_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_thw_test_cx.cpp b/test/array_thw_test_cx.cpp index dde5f654..f9deae94 100644 --- a/test/array_thw_test_cx.cpp +++ b/test/array_thw_test_cx.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/array_typedef_test.cpp b/test/array_typedef_test.cpp index d122d1dd..82010377 100644 --- a/test/array_typedef_test.cpp +++ b/test/array_typedef_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include diff --git a/test/quick.cpp b/test/quick.cpp index c59a2c64..ecb5ec0b 100644 --- a/test/quick.cpp +++ b/test/quick.cpp @@ -1,6 +1,6 @@ // Copyright 2023 Peter Dimov. // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include diff --git a/test/to_array_test.cpp b/test/to_array_test.cpp index 3bfb726b..0fd6dff9 100644 --- a/test/to_array_test.cpp +++ b/test/to_array_test.cpp @@ -1,6 +1,6 @@ // Copyright 2025 Peter Dimov // Distributed under the Boost Software License, Version 1.0. -// https://www.boost.org/LICENSE_1_0.txt) +// https://www.boost.org/LICENSE_1_0.txt #include #include From eee0d5bbc51c6b6ac55d8fd0cc0525130039fabd Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 23 Feb 2025 22:02:50 +0200 Subject: [PATCH 149/154] Update documentation --- doc/array/changes.adoc | 1 + doc/array/reference.adoc | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/doc/array/changes.adoc b/doc/array/changes.adoc index 8992e331..8f10f4c2 100644 --- a/doc/array/changes.adoc +++ b/doc/array/changes.adoc @@ -21,3 +21,4 @@ http://www.boost.org/LICENSE_1_0.txt * Removed local `hash_value` overload; `boost::hash` supports array-like types natively. * `array` can now be initialized with `= {{}}`. * Added `operator\<\=>`. +* Added `to_array`. diff --git a/doc/array/reference.adoc b/doc/array/reference.adoc index 114b27a8..2639a8be 100644 --- a/doc/array/reference.adoc +++ b/doc/array/reference.adoc @@ -42,6 +42,13 @@ namespace boost { constexpr T& get(array&) noexcept; template constexpr const T& get(const array&) noexcept; + + template + constexpr array to_array( T const (&)[N] ); + template + constexpr array to_array( T (&&)[N] ); + template + constexpr array to_array( T const (&&)[N] ); } ``` @@ -417,3 +424,29 @@ Mandates: :: `Idx < N`. Returns: :: `arr[Idx]`. --- + + +### Creation + +``` +template + constexpr array to_array( T const (&a)[N] ); +``` +[horizontal] +Returns: :: an `array` `r` such that for each `i` in `[0..N)`, `r[i]` is copied from `a[i]`. + +``` +template + constexpr array to_array( T (&&a)[N] ); +``` +[horizontal] +Returns: :: an `array` `r` such that for each `i` in `[0..N)`, `r[i]` is moved from `std::move(a[i])`. + +``` +template + constexpr array to_array( T const (&&a)[N] ); +``` +[horizontal] +Returns: :: an `array` `r` such that for each `i` in `[0..N)`, `r[i]` is copied from `a[i]`. + +--- From a0be8d9537480d0767b2443099267249c4556e41 Mon Sep 17 00:00:00 2001 From: Mohammad Nejati Date: Thu, 3 Apr 2025 14:25:37 +0330 Subject: [PATCH 150/154] Update index.html --- index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index cdbc419a..c11ef89d 100644 --- a/index.html +++ b/index.html @@ -4,8 +4,8 @@ Automatic redirection failed, please go to -doc/html/array.html  
-

© Copyright Beman Dawes, 2001

+doc/html/array.html  
+

© Copyright Beman Dawes, 2001

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)

From 8e93e2a517499a0c98be6c654add667536d3864e Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Thu, 22 Jan 2026 19:55:06 +0300 Subject: [PATCH 151/154] Remove dependencies on Boost.StaticAssert. Boost.StaticAssert has been merged into Boost.Config, so remove the dependency. --- .travis.yml | 1 - CMakeLists.txt | 1 - build.jam | 1 - test/cmake_subdir_test/CMakeLists.txt | 1 - 4 files changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f397fc54..f85958c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,6 @@ matrix: - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/assert.git ../assert - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/config.git ../config - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/core.git ../core - - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/static_assert.git ../static_assert - git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/throw_exception.git ../throw_exception script: diff --git a/CMakeLists.txt b/CMakeLists.txt index 7684b1d1..343973a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,6 @@ target_link_libraries(boost_array INTERFACE Boost::assert Boost::config - Boost::static_assert Boost::throw_exception ) diff --git a/build.jam b/build.jam index 7376d93b..95e46155 100644 --- a/build.jam +++ b/build.jam @@ -8,7 +8,6 @@ require-b2 5.2 ; constant boost_dependencies : /boost/assert//boost_assert /boost/config//boost_config - /boost/static_assert//boost_static_assert /boost/throw_exception//boost_throw_exception ; diff --git a/test/cmake_subdir_test/CMakeLists.txt b/test/cmake_subdir_test/CMakeLists.txt index ea0eae9d..8562d75c 100644 --- a/test/cmake_subdir_test/CMakeLists.txt +++ b/test/cmake_subdir_test/CMakeLists.txt @@ -11,7 +11,6 @@ add_subdirectory(../.. boostorg/array) add_subdirectory(../../../assert boostorg/assert) add_subdirectory(../../../config boostorg/config) add_subdirectory(../../../core boostorg/core) -add_subdirectory(../../../static_assert boostorg/static_assert) add_subdirectory(../../../throw_exception boostorg/throw_exception) add_executable(quick ../quick.cpp) From 7bfa9baf8d3a5fa5bf84c4cb322204d63d66b0ab Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 22 Jan 2026 22:13:57 +0200 Subject: [PATCH 152/154] Update ci.yml --- .github/workflows/ci.yml | 153 +++++++++++++++++++++++---------------- 1 file changed, 89 insertions(+), 64 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5dea8ab..efee5447 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,157 +19,205 @@ jobs: include: - toolset: gcc-4.8 cxxstd: "03,11" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest install: g++-4.8-multilib address-model: 32,64 - toolset: gcc-4.9 cxxstd: "03,11" - os: ubuntu-latest container: ubuntu:16.04 + os: ubuntu-latest install: g++-4.9-multilib address-model: 32,64 - toolset: gcc-5 cxxstd: "03,11,14,1z" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest install: g++-5-multilib address-model: 32,64 - toolset: gcc-6 cxxstd: "03,11,14,1z" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest install: g++-6-multilib address-model: 32,64 - toolset: gcc-7 cxxstd: "03,11,14,17" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: g++-7-multilib address-model: 32,64 - toolset: gcc-8 cxxstd: "03,11,14,17,2a" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: g++-8-multilib address-model: 32,64 - toolset: gcc-9 cxxstd: "03,11,14,17,2a" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: g++-9-multilib address-model: 32,64 - toolset: gcc-10 cxxstd: "03,11,14,17,2a" - os: ubuntu-22.04 + container: ubuntu:22.04 + os: ubuntu-latest install: g++-10-multilib address-model: 32,64 - toolset: gcc-11 cxxstd: "03,11,14,17,20" - os: ubuntu-22.04 + container: ubuntu:22.04 + os: ubuntu-latest install: g++-11-multilib address-model: 32,64 - toolset: gcc-12 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-22.04 + container: ubuntu:22.04 + os: ubuntu-latest install: g++-12-multilib address-model: 32,64 - toolset: gcc-13 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-24.04 + container: ubuntu:24.04 + os: ubuntu-latest install: g++-13-multilib address-model: 32,64 - toolset: gcc-14 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-24.04 + container: ubuntu:24.04 + os: ubuntu-latest install: g++-14-multilib address-model: 32,64 + - toolset: gcc-15 + cxxstd: "03,11,14,17,20,23,2c" + container: ubuntu:25.10 + os: ubuntu-latest + install: g++-15-multilib + address-model: 32,64 - toolset: clang compiler: clang++-3.9 cxxstd: "03,11,14" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest install: clang-3.9 - toolset: clang compiler: clang++-4.0 cxxstd: "03,11,14" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest install: clang-4.0 - toolset: clang compiler: clang++-5.0 cxxstd: "03,11,14,1z" - os: ubuntu-latest container: ubuntu:18.04 + os: ubuntu-latest install: clang-5.0 - toolset: clang compiler: clang++-6.0 cxxstd: "03,11,14,17" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: clang-6.0 - toolset: clang compiler: clang++-7 cxxstd: "03,11,14,17" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: clang-7 - toolset: clang compiler: clang++-8 cxxstd: "03,11,14,17" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: clang-8 - toolset: clang compiler: clang++-9 cxxstd: "03,11,14,17,2a" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest install: clang-9 - toolset: clang compiler: clang++-10 cxxstd: "03,11,14,17,2a" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest + install: clang-10 - toolset: clang compiler: clang++-11 cxxstd: "03,11,14,17,2a" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest + install: clang-11 - toolset: clang compiler: clang++-12 cxxstd: "03,11,14,17,20" - os: ubuntu-20.04 + container: ubuntu:20.04 + os: ubuntu-latest + install: clang-12 - toolset: clang compiler: clang++-13 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-22.04 + container: ubuntu:22.04 + os: ubuntu-latest install: clang-13 - toolset: clang compiler: clang++-14 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-22.04 + container: ubuntu:22.04 + os: ubuntu-latest install: clang-14 - toolset: clang compiler: clang++-15 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-22.04 + container: ubuntu:22.04 + os: ubuntu-latest install: clang-15 - toolset: clang compiler: clang++-16 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-24.04 + container: ubuntu:24.04 + os: ubuntu-latest install: clang-16 - toolset: clang compiler: clang++-17 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-24.04 + container: ubuntu:24.04 + os: ubuntu-latest install: clang-17 - toolset: clang compiler: clang++-18 cxxstd: "03,11,14,17,20,2b" - os: ubuntu-24.04 + container: ubuntu:24.04 + os: ubuntu-latest install: clang-18 - toolset: clang + compiler: clang++-19 cxxstd: "03,11,14,17,20,2b" - os: macos-13 + container: ubuntu:24.04 + os: ubuntu-latest + install: clang-19 + - toolset: clang + compiler: clang++-20 + cxxstd: "03,11,14,17,20,2b" + container: ubuntu:24.04 + os: ubuntu-latest + install: clang-20 + - toolset: clang + compiler: clang++-21 + cxxstd: "03,11,14,17,20,23,2c" + container: ubuntu:25.10 + os: ubuntu-latest + install: clang-21 - toolset: clang cxxstd: "03,11,14,17,20,2b" os: macos-14 - toolset: clang cxxstd: "03,11,14,17,20,2b" os: macos-15 + - toolset: clang + cxxstd: "03,11,14,17,20,23,2c" + os: macos-26 runs-on: ${{matrix.os}} @@ -243,26 +291,18 @@ jobs: fail-fast: false matrix: include: - - toolset: msvc-14.0 - cxxstd: 14,latest - addrmd: 32,64 - os: windows-2019 - - toolset: msvc-14.2 - cxxstd: "14,17,20,latest" - addrmd: 32,64 - os: windows-2019 - toolset: msvc-14.3 cxxstd: "14,17,20,latest" addrmd: 32,64 os: windows-2022 - toolset: clang-win - cxxstd: "14,17,latest" + cxxstd: "14,17,20,latest" addrmd: 32,64 - os: windows-2022 + os: windows-2025 - toolset: gcc cxxstd: "03,11,14,17,2a" addrmd: 64 - os: windows-2019 + os: windows-2022 runs-on: ${{matrix.os}} @@ -302,12 +342,8 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-20.04 - - os: ubuntu-22.04 - - os: ubuntu-24.04 - - os: macos-13 - - os: macos-14 - - os: macos-15 + - os: ubuntu-latest + - os: macos-latest runs-on: ${{matrix.os}} @@ -351,12 +387,8 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-20.04 - - os: ubuntu-22.04 - - os: ubuntu-24.04 - - os: macos-13 - - os: macos-14 - - os: macos-15 + - os: ubuntu-latest + - os: macos-latest runs-on: ${{matrix.os}} @@ -410,12 +442,8 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-20.04 - - os: ubuntu-22.04 - - os: ubuntu-24.04 - - os: macos-13 - - os: macos-14 - - os: macos-15 + - os: ubuntu-latest + - os: macos-latest runs-on: ${{matrix.os}} @@ -467,8 +495,7 @@ jobs: fail-fast: false matrix: include: - - os: windows-2019 - - os: windows-2022 + - os: windows-latest runs-on: ${{matrix.os}} @@ -516,8 +543,7 @@ jobs: fail-fast: false matrix: include: - - os: windows-2019 - - os: windows-2022 + - os: windows-latest runs-on: ${{matrix.os}} @@ -583,8 +609,7 @@ jobs: fail-fast: false matrix: include: - - os: windows-2019 - - os: windows-2022 + - os: windows-latest runs-on: ${{matrix.os}} From 8643c3caa891d4217d79fac8364b0aeaecac7059 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 23 Jan 2026 05:26:16 +0200 Subject: [PATCH 153/154] Update .drone.jsonnet --- .drone.jsonnet | 49 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index b65d8864..3235a3df 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -34,7 +34,6 @@ local linux_pipeline(name, image, environment, packages = "", sources = [], arch 'set -e', 'uname -a', 'echo $DRONE_STAGE_MACHINE', - 'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -', ] + (if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) + (if packages != "" then [ 'apt-get update', 'apt-get -y install ' + packages ] else []) + @@ -207,6 +206,13 @@ local windows_pipeline(name, image, environment, arch = "amd64") = "g++-14-multilib", ), + linux_pipeline( + "Linux 25.10 GCC 15 32/64", + "cppalliance/droneubuntu2510:1", + { TOOLSET: 'gcc', COMPILER: 'g++-15', CXXSTD: '11,14,17,20,23,2c', ADDRMD: '32,64' }, + "g++-15-multilib", + ), + linux_pipeline( "Linux 16.04 Clang 3.5", "cppalliance/droneubuntu1604:1", @@ -334,38 +340,45 @@ local windows_pipeline(name, image, environment, arch = "amd64") = ), linux_pipeline( - "Linux 24.04 Clang 17 UBSAN", + "Linux 24.04 Clang 17", "cppalliance/droneubuntu2404:1", - { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + ubsan, + { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' }, "clang-17", ), linux_pipeline( - "Linux 24.04 Clang 17 ASAN", + "Linux 24.04 Clang 18", "cppalliance/droneubuntu2404:1", - { TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '03,11,14,17,20,2b' } + asan, - "clang-17", + { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' }, + "clang-18", ), linux_pipeline( - "Linux 24.04 Clang 18 UBSAN", + "Linux 24.04 Clang 19", "cppalliance/droneubuntu2404:1", - { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' } + ubsan, + { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' }, "clang-18", ), linux_pipeline( - "Linux 24.04 Clang 18 ASAN", + "Linux 24.04 Clang 20 UBSAN", "cppalliance/droneubuntu2404:1", - { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' } + asan, - "clang-18", + { TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '11,14,17,20,2b' } + ubsan, + "clang-20", ), linux_pipeline( - "Linux 24.10 Clang 19", - "cppalliance/droneubuntu2410:1", - { TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '03,11,14,17,20,2b' }, - "clang-19", + "Linux 24.04 Clang 20 ASAN", + "cppalliance/droneubuntu2404:1", + { TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '11,14,17,20,2b' } + asan, + "clang-20", + ), + + linux_pipeline( + "Linux 25.10 Clang 21", + "cppalliance/droneubuntu2510:1", + { TOOLSET: 'clang', COMPILER: 'clang++-21', CXXSTD: '11,14,17,20,23,2c' }, + "clang-21", ), macos_pipeline( @@ -413,4 +426,10 @@ local windows_pipeline(name, image, environment, arch = "amd64") = "cppalliance/dronevs2022:1", { TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' }, ), + + windows_pipeline( + "Windows VS2026 msvc-14.5", + "cppalliance/dronevs2026:1", + { TOOLSET: 'msvc-14.5', CXXSTD: '14,17,20,latest' }, + ), ] From 3df3aafd1924084d46988590bd94cf4c1b362859 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 23 Jan 2026 05:53:50 +0200 Subject: [PATCH 154/154] Add back cxxstd=03 to .drone.jsonnet --- .drone.jsonnet | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.drone.jsonnet b/.drone.jsonnet index 3235a3df..afbe6484 100644 --- a/.drone.jsonnet +++ b/.drone.jsonnet @@ -349,35 +349,35 @@ local windows_pipeline(name, image, environment, arch = "amd64") = linux_pipeline( "Linux 24.04 Clang 18", "cppalliance/droneubuntu2404:1", - { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' }, + { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' }, "clang-18", ), linux_pipeline( "Linux 24.04 Clang 19", "cppalliance/droneubuntu2404:1", - { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' }, + { TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' }, "clang-18", ), linux_pipeline( "Linux 24.04 Clang 20 UBSAN", "cppalliance/droneubuntu2404:1", - { TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '11,14,17,20,2b' } + ubsan, + { TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '03,11,14,17,20,2b' } + ubsan, "clang-20", ), linux_pipeline( "Linux 24.04 Clang 20 ASAN", "cppalliance/droneubuntu2404:1", - { TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '11,14,17,20,2b' } + asan, + { TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '03,11,14,17,20,2b' } + asan, "clang-20", ), linux_pipeline( "Linux 25.10 Clang 21", "cppalliance/droneubuntu2510:1", - { TOOLSET: 'clang', COMPILER: 'clang++-21', CXXSTD: '11,14,17,20,23,2c' }, + { TOOLSET: 'clang', COMPILER: 'clang++-21', CXXSTD: '03,11,14,17,20,23,2c' }, "clang-21", ),