Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84823 - in branches/release: boost/range boost/range/adaptor boost/range/detail libs/range libs/range/test libs/range/test/adaptor_test
From: zeratul976_at_[hidden]
Date: 2013-06-17 22:22:07


Author: nathanridge
Date: 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013)
New Revision: 84823
URL: http://svn.boost.org/trac/boost/changeset/84823

Log:
[range] Merge Boost.Range bug fixes to release branch (fixes #6944; fixes #7407; fixes #7408; fixes #7731; fixes #7827; fixes #8338; fixes #8453).

Added:
   branches/release/libs/range/test/test_utils.hpp
      - copied unchanged from r84822, trunk/libs/range/test/test_utils.hpp
   branches/release/libs/range/test/ticket_6944.cpp
      - copied unchanged from r84822, trunk/libs/range/test/ticket_6944.cpp
Properties modified:
   branches/release/boost/range/ (props changed)
   branches/release/libs/range/ (props changed)
Text files modified:
   branches/release/boost/range/adaptor/indexed.hpp | 3 ++
   branches/release/boost/range/concepts.hpp | 8 +++---
   branches/release/boost/range/detail/extract_optional_type.hpp | 2
   branches/release/boost/range/irange.hpp | 2
   branches/release/boost/range/istream_range.hpp | 6 ++--
   branches/release/boost/range/iterator_range_core.hpp | 5 +++
   branches/release/libs/range/test/Jamfile.v2 | 1
   branches/release/libs/range/test/adaptor_test/indexed.cpp | 6 +++++
   branches/release/libs/range/test/irange.cpp | 18 +++++----------
   branches/release/libs/range/test/istream_range.cpp | 15 +++++++++---
   branches/release/libs/range/test/iterator_range.cpp | 5 ++++
   branches/release/libs/range/test/test_utils.hpp | 24 ++++++++++++++++++++
   branches/release/libs/range/test/ticket_6944.cpp | 46 ++++++++++++++++++++++++++++++++++++++++
   13 files changed, 115 insertions(+), 26 deletions(-)

Modified: branches/release/boost/range/adaptor/indexed.hpp
==============================================================================
--- branches/release/boost/range/adaptor/indexed.hpp Mon Jun 17 20:18:41 2013 (r84822)
+++ branches/release/boost/range/adaptor/indexed.hpp 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013) (r84823)
@@ -55,6 +55,9 @@
             index_type m_index;
 
         public:
+ indexed_iterator()
+ : m_index(index_type()) {}
+
             explicit indexed_iterator( Iter i, index_type index )
             : base(i), m_index(index)
             {

Modified: branches/release/boost/range/concepts.hpp
==============================================================================
--- branches/release/boost/range/concepts.hpp Mon Jun 17 20:18:41 2013 (r84822)
+++ branches/release/boost/range/concepts.hpp 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013) (r84823)
@@ -330,8 +330,8 @@
     struct BidirectionalRangeConcept : ForwardRangeConcept<T>
     {
 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
- BOOST_RANGE_CONCEPT_ASSERT((BidirectionalIteratorConcept<BOOST_DEDUCED_TYPENAME BidirectionalRangeConcept::iterator>));
- BOOST_RANGE_CONCEPT_ASSERT((BidirectionalIteratorConcept<BOOST_DEDUCED_TYPENAME BidirectionalRangeConcept::const_iterator>));
+ BOOST_RANGE_CONCEPT_ASSERT((range_detail::BidirectionalIteratorConcept<BOOST_DEDUCED_TYPENAME BidirectionalRangeConcept::iterator>));
+ BOOST_RANGE_CONCEPT_ASSERT((range_detail::BidirectionalIteratorConcept<BOOST_DEDUCED_TYPENAME BidirectionalRangeConcept::const_iterator>));
 #endif
     };
 
@@ -348,8 +348,8 @@
     struct RandomAccessRangeConcept : BidirectionalRangeConcept<T>
     {
 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
- BOOST_RANGE_CONCEPT_ASSERT((RandomAccessIteratorConcept<BOOST_DEDUCED_TYPENAME RandomAccessRangeConcept::iterator>));
- BOOST_RANGE_CONCEPT_ASSERT((RandomAccessIteratorConcept<BOOST_DEDUCED_TYPENAME RandomAccessRangeConcept::const_iterator>));
+ BOOST_RANGE_CONCEPT_ASSERT((range_detail::RandomAccessIteratorConcept<BOOST_DEDUCED_TYPENAME RandomAccessRangeConcept::iterator>));
+ BOOST_RANGE_CONCEPT_ASSERT((range_detail::RandomAccessIteratorConcept<BOOST_DEDUCED_TYPENAME RandomAccessRangeConcept::const_iterator>));
 #endif
     };
 

Modified: branches/release/boost/range/detail/extract_optional_type.hpp
==============================================================================
--- branches/release/boost/range/detail/extract_optional_type.hpp Mon Jun 17 20:18:41 2013 (r84822)
+++ branches/release/boost/range/detail/extract_optional_type.hpp 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013) (r84823)
@@ -16,7 +16,7 @@
 
 #include <boost/config.hpp>
 
-#ifdef BOOST_NO_PARTIAL_TEMPLATE_SPECIALIZATION
+#ifdef BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS
 
 #define BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( a_typedef ) \
     template< typename C > \

Modified: branches/release/boost/range/irange.hpp
==============================================================================
--- branches/release/boost/range/irange.hpp Mon Jun 17 20:18:41 2013 (r84822)
+++ branches/release/boost/range/irange.hpp 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013) (r84823)
@@ -217,7 +217,7 @@
         const std::ptrdiff_t sz = static_cast<std::ptrdiff_t>(step_size >= 0 ? step_size : -step_size);
         const Integer l = step_size >= 0 ? last : first;
         const Integer f = step_size >= 0 ? first : last;
- const std::ptrdiff_t num_steps = (l + ((l-f) % sz) - f) / sz;
+ const std::ptrdiff_t num_steps = (l - f) / sz + ((l - f) % sz ? 1 : 0);
         BOOST_ASSERT(num_steps >= 0);
        
         return strided_integer_range<Integer>(

Modified: branches/release/boost/range/istream_range.hpp
==============================================================================
--- branches/release/boost/range/istream_range.hpp Mon Jun 17 20:18:41 2013 (r84822)
+++ branches/release/boost/range/istream_range.hpp 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013) (r84823)
@@ -14,7 +14,7 @@
  */
 
 #include <iterator>
-#include <istream>
+#include <iosfwd>
 #include <boost/config.hpp>
 #include <boost/range/iterator_range.hpp>
 
@@ -27,8 +27,8 @@
         istream_range(std::basic_istream<Elem, Traits>& in)
         {
             return iterator_range<std::istream_iterator<Type, Elem, Traits> >(
- std::istream_iterator<Type>(in),
- std::istream_iterator<Type>());
+ std::istream_iterator<Type, Elem, Traits>(in),
+ std::istream_iterator<Type, Elem, Traits>());
         }
     } // namespace range
     using range::istream_range;

Modified: branches/release/boost/range/iterator_range_core.hpp
==============================================================================
--- branches/release/boost/range/iterator_range_core.hpp Mon Jun 17 20:18:41 2013 (r84822)
+++ branches/release/boost/range/iterator_range_core.hpp 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013) (r84823)
@@ -21,7 +21,9 @@
 #include <boost/assert.hpp>
 #include <boost/iterator/iterator_traits.hpp>
 #include <boost/iterator/iterator_facade.hpp>
+#include <boost/mpl/or.hpp>
 #include <boost/type_traits/is_abstract.hpp>
+#include <boost/type_traits/is_array.hpp>
 #include <boost/type_traits/is_pointer.hpp>
 #include <boost/range/functions.hpp>
 #include <boost/range/iterator.hpp>
@@ -167,7 +169,8 @@
 
         private: // for return value of operator()()
             typedef BOOST_DEDUCED_TYPENAME
- boost::mpl::if_< boost::is_abstract<value_type>,
+ boost::mpl::if_< boost::mpl::or_< boost::is_abstract< value_type >,
+ boost::is_array< value_type > >,
                                  reference, value_type >::type abstract_value_type;
 
         public:

Modified: branches/release/libs/range/test/Jamfile.v2
==============================================================================
--- branches/release/libs/range/test/Jamfile.v2 Mon Jun 17 20:18:41 2013 (r84822)
+++ branches/release/libs/range/test/Jamfile.v2 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013) (r84823)
@@ -161,5 +161,6 @@
         [ range-test ticket_5544_terminate_irange ]
         [ range-test ticket_5547 ]
         [ range-test ticket_5556_is_sorted_namespace ]
+ [ range-test ticket_6944 ]
     ;
 

Modified: branches/release/libs/range/test/adaptor_test/indexed.cpp
==============================================================================
--- branches/release/libs/range/test/adaptor_test/indexed.cpp Mon Jun 17 20:18:41 2013 (r84822)
+++ branches/release/libs/range/test/adaptor_test/indexed.cpp 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013) (r84823)
@@ -15,11 +15,14 @@
 
 #include <boost/assign.hpp>
 #include <boost/range/algorithm_ext.hpp>
+#include <boost/range/concepts.hpp>
 
 #include <algorithm>
 #include <list>
 #include <vector>
 
+#include "../test_utils.hpp"
+
 namespace boost
 {
     namespace
@@ -83,6 +86,9 @@
         {
             indexed_test_impl< std::vector< int > >();
             indexed_test_impl< std::list< int > >();
+
+ check_random_access_range_concept(std::vector<int>() | boost::adaptors::indexed(0));
+ check_bidirectional_range_concept(std::list<int>() | boost::adaptors::indexed(0));
         }
     }
 }

Modified: branches/release/libs/range/test/irange.cpp
==============================================================================
--- branches/release/libs/range/test/irange.cpp Mon Jun 17 20:18:41 2013 (r84822)
+++ branches/release/libs/range/test/irange.cpp 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013) (r84823)
@@ -35,15 +35,6 @@
                                        reference.begin(), reference.end() );
     }
     
- template<typename Integer>
- std::ptrdiff_t test_irange_calculate_num_steps(Integer first, Integer last, int step)
- {
- const std::ptrdiff_t sz = static_cast<std::ptrdiff_t>(step >= 0 ? step : -step);
- const std::ptrdiff_t l = static_cast<std::ptrdiff_t>(step >= 0 ? last : first);
- const std::ptrdiff_t f = static_cast<std::ptrdiff_t>(step >= 0 ? first : last);
- return (l + ((l-f) % sz) - f) / sz;
- }
-
     // Test an integer range with a runtime specified step size.
     template<typename Integer, typename IntegerInput>
     void test_irange_impl(IntegerInput first, IntegerInput last, int step)
@@ -58,9 +49,12 @@
         
         std::vector<Integer> reference;
 
- const std::ptrdiff_t num_steps = test_irange_calculate_num_steps(first, last, step);
- Integer current_value = first;
- for (std::ptrdiff_t i = 0; i < num_steps; ++i, current_value += step)
+ const std::ptrdiff_t first_p = static_cast<std::ptrdiff_t>(first);
+ const std::ptrdiff_t last_p = static_cast<std::ptrdiff_t>(last);
+ const std::ptrdiff_t step_p = static_cast<std::ptrdiff_t>(step);
+ for (std::ptrdiff_t current_value = first_p;
+ step_p >= 0 ? current_value < last_p : current_value > last_p;
+ current_value += step_p)
             reference.push_back(current_value);
 
         std::vector<Integer> test;

Modified: branches/release/libs/range/test/istream_range.cpp
==============================================================================
--- branches/release/libs/range/test/istream_range.cpp Mon Jun 17 20:18:41 2013 (r84822)
+++ branches/release/libs/range/test/istream_range.cpp 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013) (r84823)
@@ -19,15 +19,15 @@
 
 namespace
 {
- // Test an integer range with a step size of 1.
- void test_istream_range()
+ template <typename CharT>
+ void test_istream_range_impl()
     {
- std::stringstream s;
+ std::basic_stringstream<CharT> s;
         std::vector<int> reference;
         for (int i = 0; i < 10; ++i)
         {
             reference.push_back(i);
- s << i << " ";
+ s << i << CharT(' ');
         }
 
         std::vector<int> target;
@@ -36,6 +36,13 @@
         BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(),
             target.begin(), target.end() );
     }
+
+ // Test an istream range.
+ void test_istream_range()
+ {
+ test_istream_range_impl<char>();
+ test_istream_range_impl<wchar_t>();
+ }
 
 } // namespace anonymous namespace
 

Modified: branches/release/libs/range/test/iterator_range.cpp
==============================================================================
--- branches/release/libs/range/test/iterator_range.cpp Mon Jun 17 20:18:41 2013 (r84822)
+++ branches/release/libs/range/test/iterator_range.cpp 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013) (r84823)
@@ -101,6 +101,11 @@
     BOOST_CHECK( rrr == str );
 
     check_reference_type();
+
+ // Check that an iterator range can be instantiated with
+ // a pointer to an array as an iterator.
+ int arr[2][2];
+ boost::make_iterator_range(arr, arr + 2);
 }
 
 namespace iterator_range_test_detail

Copied: branches/release/libs/range/test/test_utils.hpp (from r84822, trunk/libs/range/test/test_utils.hpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/range/test/test_utils.hpp 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013) (r84823, copy of r84822, trunk/libs/range/test/test_utils.hpp)
@@ -0,0 +1,24 @@
+// Boost.Range library
+//
+// Copyright Akira Takahashi 2013. 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/concepts.hpp>
+
+template <class RandomAccessRng>
+void check_random_access_range_concept(const RandomAccessRng& rng)
+{
+ BOOST_RANGE_CONCEPT_ASSERT(( boost::RandomAccessRangeConcept<RandomAccessRng> ));
+}
+
+template <class BidirectionalRng>
+void check_bidirectional_range_concept(const BidirectionalRng& rng)
+{
+ BOOST_RANGE_CONCEPT_ASSERT(( boost::BidirectionalRangeConcept<BidirectionalRng> ));
+}

Copied: branches/release/libs/range/test/ticket_6944.cpp (from r84822, trunk/libs/range/test/ticket_6944.cpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/range/test/ticket_6944.cpp 2013-06-17 22:22:07 EDT (Mon, 17 Jun 2013) (r84823, copy of r84822, trunk/libs/range/test/ticket_6944.cpp)
@@ -0,0 +1,46 @@
+// 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/concept_check.hpp>
+#include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/range/concepts.hpp>
+#include <boost/range/iterator_range.hpp>
+
+#include <boost/test/test_tools.hpp>
+#include <boost/test/unit_test.hpp>
+
+#include <vector>
+
+namespace boost
+{
+ typedef std::vector<int>::iterator iter_base;
+ struct iter : boost::iterator_adaptor<iter, iter_base, int, boost::use_default, int> {}; // will be deduced as random-access traversal but input category
+ typedef boost::iterator_range<iter> iter_range;
+
+ namespace
+ {
+ // Ticket 6944 - Some Range concepts use the incorrect Iterator concept
+ void test_ticket_6944()
+ {
+ BOOST_CONCEPT_ASSERT(( boost::RandomAccessRangeConcept<iter_range> ));
+ }
+ }
+}
+
+boost::unit_test::test_suite*
+init_unit_test_suite(int argc, char* argv[])
+{
+ boost::unit_test::test_suite* test
+ = BOOST_TEST_SUITE( "RangeTestSuite.ticket_6944" );
+
+ test->add( BOOST_TEST_CASE( &boost::test_ticket_6944 ) );
+
+ return test;
+}


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