From 4c2898345972bd6c44c6b55abb386af931cc8fb5 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Tue, 20 Aug 2013 06:06:12 +0000 Subject: [PATCH] [range] Fixed a bug in join_iterator where joining a const range and a non-const range led to a compiler error (refs #8483). [SVN r85400] --- include/boost/range/detail/join_iterator.hpp | 8 ++++++-- test/join.cpp | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/boost/range/detail/join_iterator.hpp b/include/boost/range/detail/join_iterator.hpp index bbdeec7..70ecf65 100644 --- a/include/boost/range/detail/join_iterator.hpp +++ b/include/boost/range/detail/join_iterator.hpp @@ -143,8 +143,12 @@ template::type >::type >::value, - typename add_const< - typename iterator_reference::type + typename add_reference< + typename add_const< + typename remove_reference< + typename iterator_reference::type + >::type + >::type >::type, typename iterator_reference::type >::type diff --git a/test/join.cpp b/test/join.cpp index 290e651..b30d060 100644 --- a/test/join.cpp +++ b/test/join.cpp @@ -257,6 +257,18 @@ namespace boost test_join_impl< std::vector, std::deque >(); test_join_impl< std::deque, std::vector >(); } + + void test_join_iterator_reference_type_constness_ticket8483() + { + // Just test that this compiles. + // Before the fix for bug 8483, the reference type of the joined + // range's iterator was incorrect ('int&' instead of 'const int&'), + // causing compiler errors. + const std::vector v1; + std::vector v2; + std::vector joined; + boost::push_back(joined, join(v1, v2)); + } } } @@ -268,6 +280,7 @@ init_unit_test_suite(int argc, char* argv[]) = BOOST_TEST_SUITE( "RangeTestSuite.adaptor.joined" ); test->add( BOOST_TEST_CASE( &boost::join_test ) ); + test->add( BOOST_TEST_CASE( &boost::test_join_iterator_reference_type_constness_ticket8483 ) ); return test; }