|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70041 - trunk/boost/range/detail
From: neil_at_[hidden]
Date: 2011-03-16 19:55:29
Author: neilgroves
Date: 2011-03-16 19:55:25 EDT (Wed, 16 Mar 2011)
New Revision: 70041
URL: http://svn.boost.org/trac/boost/changeset/70041
Log:
[range] - Improved default Reference type deduction for the join_iterator as implemented by aschoedl in Trac issue 5061.
Text files modified:
trunk/boost/range/detail/join_iterator.hpp | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
Modified: trunk/boost/range/detail/join_iterator.hpp
==============================================================================
--- trunk/boost/range/detail/join_iterator.hpp (original)
+++ trunk/boost/range/detail/join_iterator.hpp 2011-03-16 19:55:25 EDT (Wed, 16 Mar 2011)
@@ -5,6 +5,9 @@
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
+// Acknowledgements:
+// aschoedl contributed an improvement to the determination
+// of the Reference type parameter.
//
// For more information, see http://www.boost.org/libs/range/
//
@@ -120,7 +123,32 @@
template<typename Iterator1
, typename Iterator2
, typename ValueType = typename iterator_value<Iterator1>::type
- , typename Reference = typename iterator_reference<Iterator1>::type
+ // find least demanding, commonly supported reference type, in the order &, const&, and by-value:
+ , typename Reference = typename mpl::if_c<
+ !is_reference<typename iterator_reference<Iterator1>::type>::value
+ || !is_reference<typename iterator_reference<Iterator2>::type>::value,
+ typename remove_const<
+ typename remove_reference<
+ typename iterator_reference<Iterator1>::type
+ >::type
+ >::type,
+ typename mpl::if_c<
+ is_const<
+ typename remove_reference<
+ typename iterator_reference<Iterator1>::type
+ >::type
+ >::value
+ || is_const<
+ typename remove_reference<
+ typename iterator_reference<Iterator2>::type
+ >::type
+ >::value,
+ typename add_const<
+ typename iterator_reference<Iterator2>::type
+ >::type,
+ typename iterator_reference<Iterator1>::type
+ >::type
+ >::type
, typename Traversal = typename demote_iterator_traversal_tag<
typename iterator_traversal<Iterator1>::type
, typename iterator_traversal<Iterator2>::type>::type
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