Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70852 - in trunk: boost/range libs/range/test libs/range/test/compile_fail
From: neil_at_[hidden]
Date: 2011-04-02 09:05:26


Author: neilgroves
Date: 2011-04-02 09:05:26 EDT (Sat, 02 Apr 2011)
New Revision: 70852
URL: http://svn.boost.org/trac/boost/changeset/70852

Log:
[boost][range] - Resolved Trace 5162 - boost::iterator_range<T*> is unsafe.
Added:
   trunk/libs/range/test/compile_fail/
   trunk/libs/range/test/compile_fail/iterator_range1.cpp (contents, props changed)
Text files modified:
   trunk/boost/range/iterator_range_core.hpp | 4 ++--
   trunk/libs/range/test/Jamfile.v2 | 1 +
   trunk/libs/range/test/iterator_range.cpp | 9 +++++++++
   3 files changed, 12 insertions(+), 2 deletions(-)

Modified: trunk/boost/range/iterator_range_core.hpp
==============================================================================
--- trunk/boost/range/iterator_range_core.hpp (original)
+++ trunk/boost/range/iterator_range_core.hpp 2011-04-02 09:05:26 EDT (Sat, 02 Apr 2011)
@@ -53,13 +53,13 @@
             template< class ForwardRange >
             static IteratorT adl_begin( ForwardRange& r )
             {
- return IteratorT( boost::begin( r ) );
+ return static_cast<IteratorT>( boost::begin( r ) );
             }
 
             template< class ForwardRange >
             static IteratorT adl_end( ForwardRange& r )
             {
- return IteratorT( boost::end( r ) );
+ return static_cast<IteratorT>( boost::end( r ) );
             }
         };
 

Modified: trunk/libs/range/test/Jamfile.v2
==============================================================================
--- trunk/libs/range/test/Jamfile.v2 (original)
+++ trunk/libs/range/test/Jamfile.v2 2011-04-02 09:05:26 EDT (Sat, 02 Apr 2011)
@@ -31,6 +31,7 @@
 }
 
 test-suite range :
+ [ compile-fail compile_fail/iterator_range1.cpp ]
         [ range-test adaptor_test/adjacent_filtered ]
         [ range-test adaptor_test/copied ]
         [ range-test adaptor_test/filtered ]

Added: trunk/libs/range/test/compile_fail/iterator_range1.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/range/test/compile_fail/iterator_range1.cpp 2011-04-02 09:05:26 EDT (Sat, 02 Apr 2011)
@@ -0,0 +1,21 @@
+// Boost.Range library
+//
+// Copyright Neil Groves 2011. Use, modification and distribution is subject
+// to 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)
+//
+// For more information, see http://www.boost.org/libs/range
+//
+
+#include <boost/range/iterator_range_core.hpp>
+
+namespace iterator_range_test_detail
+{
+ void check_iterator_range_doesnt_convert_pointers()
+ {
+ double source[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 };
+ boost::iterator_range<float*> rng = boost::make_iterator_range(source);
+ }
+}
+

Modified: trunk/libs/range/test/iterator_range.cpp
==============================================================================
--- trunk/libs/range/test/iterator_range.cpp (original)
+++ trunk/libs/range/test/iterator_range.cpp 2011-04-02 09:05:26 EDT (Sat, 02 Apr 2011)
@@ -200,6 +200,15 @@
             }
         }
     }
+
+ void check_iterator_range_from_array()
+ {
+ double source[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 };
+ boost::iterator_range<double*> rng = boost::make_iterator_range(source);
+ BOOST_CHECK_EQUAL_COLLECTIONS( rng.begin(), rng.end(),
+ source, source + 6 );
+ }
+
 } // namespace iterator_range_test_detail
 
 template<typename Pred>


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