Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68100 - in branches/release: boost libs/array libs/array/doc libs/array/test
From: marshall_at_[hidden]
Date: 2011-01-13 10:49:07


Author: marshall
Date: 2011-01-13 10:49:03 EST (Thu, 13 Jan 2011)
New Revision: 68100
URL: http://svn.boost.org/trac/boost/changeset/68100

Log:
Merging changes to release; fixes #4761
Properties modified:
   branches/release/boost/array.hpp (contents, props changed)
   branches/release/libs/array/ (props changed)
   branches/release/libs/array/doc/array.xml (props changed)
   branches/release/libs/array/test/Jamfile.v2 (props changed)
   branches/release/libs/array/test/array0.cpp (contents, props changed)
   branches/release/libs/array/test/array2.cpp (props changed)
   branches/release/libs/array/test/array6.cpp (props changed)
Text files modified:
   branches/release/boost/array.hpp | 53 +++++++++++++++++++++++++++------------
   branches/release/libs/array/test/array0.cpp | 8 ++++++
   branches/release/libs/array/test/array3.cpp | 7 +++++
   3 files changed, 52 insertions(+), 16 deletions(-)

Modified: branches/release/boost/array.hpp
==============================================================================
--- branches/release/boost/array.hpp (original)
+++ branches/release/boost/array.hpp 2011-01-13 10:49:03 EST (Thu, 13 Jan 2011)
@@ -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 <http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#776> or Trac issue #3168
  * Eventually, we should remove "assign" which is now a synonym for "fill" (Marshall Clow)
@@ -69,10 +70,13 @@
         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 @@
         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 @@
         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 @@
         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 @@
     }
 
 #if defined(__SUNPRO_CC)
-// Trac ticket #4757; the Sun Solaris compiler can't handle
-// syntax like 'T(&get_c_array(boost::array<T,N>& 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<T,N>& arg))[N]'
+//
+// We can't just use this for all compilers, because the
+// borland compilers can't handle this form.
+ namespace detail {
        template <typename T, std::size_t N> struct c_array
        {
            typedef T type[N];
        };
- }
+ }
     
    // Specific for boost::array: simply returns its elems data member.
    template <typename T, std::size_t N>
@@ -387,7 +408,7 @@
         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

Modified: branches/release/libs/array/test/array0.cpp
==============================================================================
--- branches/release/libs/array/test/array0.cpp (original)
+++ branches/release/libs/array/test/array0.cpp 2011-01-13 10:49:03 EST (Thu, 13 Jan 2011)
@@ -56,9 +56,15 @@
     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 @@
     // 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 );

Modified: branches/release/libs/array/test/array3.cpp
==============================================================================
--- branches/release/libs/array/test/array3.cpp (original)
+++ branches/release/libs/array/test/array3.cpp 2011-01-13 10:49:03 EST (Thu, 13 Jan 2011)
@@ -39,6 +39,13 @@
            =seasons.rbegin(); pos<seasons.rend(); ++pos) {
         std::cout << " " << *pos;
     }
+
+ // try constant reverse iterators
+ std::cout << "reverse: ";
+ for (boost::array<std::string,4>::const_reverse_iterator pos
+ =seasons.crbegin(); pos<seasons.crend(); ++pos) {
+ std::cout << " " << *pos;
+ }
     std::cout << std::endl;
 
     return 0; // makes Visual-C++ compiler happy


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk