From 1f8298fb087b4c07efce300c489d7b08f6751e7d Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 21 Mar 2006 02:26:31 +0000 Subject: [PATCH 01/30] 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 02/30] 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 0000000..e6e5e8b --- /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 ce9eda7..841ed76 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 03/30] 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 841ed76..102664e 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 04/30] 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 102664e..7eef6af 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 05/30] 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 7eef6af..21e5f1b 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 06/30] (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 21e5f1b..b41c656 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 07/30] 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 588f27e..a9e3c34 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 08/30] 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 e09c0c0..fca63a6 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 09/30] 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 10/30] 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 11/30] 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 b41c656..52218aa 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 12/30] 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 e6e5e8b..065256b 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 13/30] 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 0000000..1379a5b --- /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 14/30] 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 0000000..39a2788 --- /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 0000000..ccd2813 --- /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 0000000..2301077 --- /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 15/30] 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 52218aa..8ef73c4 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 a4eac5d..b815fe7 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 d6c472a..23156b9 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 16/30] 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 39a2788..ecdd503 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 2301077..379e7b1 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 17/30] 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 ecdd503..0000000 --- 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 ccd2813..0000000 --- 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 379e7b1..0000000 --- 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 18/30] 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 8ef73c4..d58b93a 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 19/30] 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 d58b93a..6496469 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 065256b..92135f1 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 20/30] 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 6496469..7df2771 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 abbc745..1c8ccf8 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 21/30] 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 7df2771..a5bee24 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 1379a5b..2deb3d5 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 0000000..388b39f --- /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 22/30] 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 a5bee24..85b63a2 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 92135f1..d75db76 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 b815fe7..29aacb1 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 23/30] 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 1c8ccf8..b33e0b5 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 388b39f..658cec6 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 24/30] 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 85b63a2..ffb504b 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 25/30] 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 2deb3d5..a09ba68 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 0000000..474e29c --- /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 26/30] 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 ffb504b..fa06fa9 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 27/30] 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 fca63a6..62bf7c2 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 28/30] 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 a09ba68..5037474 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 d75db76..c1c047e 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() ); - } + BOOST_CHECK ( test_case.empty()); + BOOST_CHECK ( const_test_case.empty()); - 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 ] ); - } + 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 658cec6..3d737fd 100644 --- a/test/array6.cpp +++ b/test/array6.cpp @@ -10,39 +10,31 @@ #include #include +#define BOOST_TEST_MAIN +#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 }; + 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 474e29c..a83eead 100644 --- a/test/array_hash.cpp +++ b/test/array_hash.cpp @@ -11,39 +11,33 @@ #include #include +#define BOOST_TEST_MAIN +#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 ()); + 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 29/30] 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 62bf7c2..fb1f51f 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 30/30] 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 0000000..b7f51b7 --- /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 ;