|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67478 - in trunk: boost libs/array/test
From: marshall_at_[hidden]
Date: 2010-12-28 13:39:20
Author: marshall
Date: 2010-12-28 13:39:14 EST (Tue, 28 Dec 2010)
New Revision: 67478
URL: http://svn.boost.org/trac/boost/changeset/67478
Log:
Added cbegin and cend to Boost.Array; refs #4761. Will close ticket when merged to release branch
Text files modified:
trunk/boost/array.hpp | 23 +++++++++++++++--------
trunk/libs/array/test/array0.cpp | 8 ++++++++
2 files changed, 23 insertions(+), 8 deletions(-)
Modified: trunk/boost/array.hpp
==============================================================================
--- trunk/boost/array.hpp (original)
+++ trunk/boost/array.hpp 2010-12-28 13:39:14 EST (Tue, 28 Dec 2010)
@@ -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 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)
@@ -200,10 +204,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)
Modified: trunk/libs/array/test/array0.cpp
==============================================================================
--- trunk/libs/array/test/array0.cpp (original)
+++ trunk/libs/array/test/array0.cpp 2010-12-28 13:39:14 EST (Tue, 28 Dec 2010)
@@ -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 );
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