From 474c62ab16e72153535883fd83c78dab62fc7967 Mon Sep 17 00:00:00 2001 From: Masahide Sakamaki Date: Wed, 4 Feb 2015 15:52:15 +0900 Subject: [PATCH 01/39] fix missing return statement --- include/boost/range/algorithm_ext/insert.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/range/algorithm_ext/insert.hpp b/include/boost/range/algorithm_ext/insert.hpp index c0c04c8..51f1b8e 100644 --- a/include/boost/range/algorithm_ext/insert.hpp +++ b/include/boost/range/algorithm_ext/insert.hpp @@ -39,6 +39,7 @@ inline Container& insert( Container& on, const Range& from ) BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); on.insert(boost::begin(from), boost::end(from)); + return on; } } // namespace range From 9ca1622dd038693ac84ef5413224c44993d29d91 Mon Sep 17 00:00:00 2001 From: nekko1119 Date: Wed, 22 Apr 2015 02:26:19 +0900 Subject: [PATCH 02/39] Fix parameters in replaced adaptor document --- doc/reference/adaptors/replaced.qbk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/reference/adaptors/replaced.qbk b/doc/reference/adaptors/replaced.qbk index 3afb2c5..1c34ab9 100644 --- a/doc/reference/adaptors/replaced.qbk +++ b/doc/reference/adaptors/replaced.qbk @@ -7,8 +7,8 @@ [table [[Syntax] [Code]] - [[Pipe] [`rng | boost::adaptors::replaced(new_value, old_value)`]] - [[Function] [`boost::adaptors::replace(rng, new_value, old_value)`]] + [[Pipe] [`rng | boost::adaptors::replaced(old_value, new_value)`]] + [[Function] [`boost::adaptors::replace(rng, old_value, new_value)`]] ] * [*Precondition:] From 09084d63551798c5848a4cff033052c265ab86c5 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Mon, 27 Apr 2015 13:18:48 -0400 Subject: [PATCH 03/39] Use || operator instead of boost::mpl::or_ for constant boolean value since current Boost compilers all support operator use. --- include/boost/range/detail/common.hpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/boost/range/detail/common.hpp b/include/boost/range/detail/common.hpp index 00b665b..c50a5d8 100644 --- a/include/boost/range/detail/common.hpp +++ b/include/boost/range/detail/common.hpp @@ -18,10 +18,8 @@ #include #include #include -#include #include #include -#include #include ////////////////////////////////////////////////////////////////////////////// @@ -71,7 +69,7 @@ namespace boost BOOST_STATIC_CONSTANT( bool, is_const_wchar_t_ptr_ = sizeof( boost::range_detail::is_const_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) ); BOOST_STATIC_CONSTANT( bool, is_char_array_ = sizeof( boost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) ); BOOST_STATIC_CONSTANT( bool, is_wchar_t_array_ = sizeof( boost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) ); - BOOST_STATIC_CONSTANT( bool, is_string_ = (boost::mpl::or_, boost::mpl::bool_ >::value )); + BOOST_STATIC_CONSTANT( bool, is_string_ = (is_const_char_ptr_ || is_const_wchar_t_ptr_); BOOST_STATIC_CONSTANT( bool, is_array_ = boost::is_array::value ); }; From 0c930a3697e3084fa4ed01a5486be43c85abaeb9 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Mon, 27 Apr 2015 14:06:59 -0400 Subject: [PATCH 04/39] Fix syntax error. --- include/boost/range/detail/common.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/range/detail/common.hpp b/include/boost/range/detail/common.hpp index c50a5d8..2cbc554 100644 --- a/include/boost/range/detail/common.hpp +++ b/include/boost/range/detail/common.hpp @@ -69,7 +69,7 @@ namespace boost BOOST_STATIC_CONSTANT( bool, is_const_wchar_t_ptr_ = sizeof( boost::range_detail::is_const_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) ); BOOST_STATIC_CONSTANT( bool, is_char_array_ = sizeof( boost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) ); BOOST_STATIC_CONSTANT( bool, is_wchar_t_array_ = sizeof( boost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) ); - BOOST_STATIC_CONSTANT( bool, is_string_ = (is_const_char_ptr_ || is_const_wchar_t_ptr_); + BOOST_STATIC_CONSTANT( bool, is_string_ = (is_const_char_ptr_ || is_const_wchar_t_ptr_)); BOOST_STATIC_CONSTANT( bool, is_array_ = boost::is_array::value ); }; From 11dbb1cb5a3b78b09a5a8abd83bb267c8e3cc6b3 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 12 May 2015 21:26:05 -0600 Subject: [PATCH 05/39] Add char16_t and char32_t to the list of literal string types. Fixes bug 11265 in Boost.StringAlgo's join. --- include/boost/range/as_literal.hpp | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/include/boost/range/as_literal.hpp b/include/boost/range/as_literal.hpp index 1c16e4a..5d8c436 100644 --- a/include/boost/range/as_literal.hpp +++ b/include/boost/range/as_literal.hpp @@ -25,6 +25,11 @@ #include #include + +#if !defined(BOOST_NO_CHAR16_T) || !defined(BOOST_NO_CHAR32_T) +#include // for std::char_traits +#endif + #ifndef BOOST_NO_CWCHAR #include #endif @@ -38,6 +43,20 @@ namespace boost return strlen( s ); } +#ifndef BOOST_NO_CHAR16_T + inline std::size_t length( const char16_t* s ) + { + return std::char_traits::length( s ); + } +#endif + +#ifndef BOOST_NO_CHAR32_T + inline std::size_t length( const char32_t* s ) + { + return std::char_traits::length( s ); + } +#endif + #ifndef BOOST_NO_CWCHAR inline std::size_t length( const wchar_t* s ) { @@ -61,6 +80,30 @@ namespace boost return true; } +#ifndef BOOST_NO_CHAR16_T + inline bool is_char_ptr( char16_t* ) + { + return true; + } + + inline bool is_char_ptr( const char16_t* ) + { + return true; + } +#endif + +#ifndef BOOST_NO_CHAR32_T + inline bool is_char_ptr( char32_t* ) + { + return true; + } + + inline bool is_char_ptr( const char32_t* ) + { + return true; + } +#endif + #ifndef BOOST_NO_CWCHAR inline bool is_char_ptr( wchar_t* ) { From adcb071dc6b06e69aa4ddcc080d23695a5da378f Mon Sep 17 00:00:00 2001 From: morinmorin Date: Thu, 20 Aug 2015 20:03:08 +0900 Subject: [PATCH 06/39] Replace std::min_element/max_element with boost::first_min_element/first_max_element to accept a range that models ForwardRange but its underlying iterator models only InputIterator; fixes ticket 11528. --- include/boost/range/algorithm/max_element.hpp | 18 +++++++++--------- include/boost/range/algorithm/min_element.hpp | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/boost/range/algorithm/max_element.hpp b/include/boost/range/algorithm/max_element.hpp index a0c1ffd..dd2b9cb 100644 --- a/include/boost/range/algorithm/max_element.hpp +++ b/include/boost/range/algorithm/max_element.hpp @@ -9,12 +9,12 @@ #ifndef BOOST_RANGE_ALGORITHM_MAX_ELEMENT_HPP_INCLUDED #define BOOST_RANGE_ALGORITHM_MAX_ELEMENT_HPP_INCLUDED +#include #include #include #include #include #include -#include namespace boost { @@ -32,7 +32,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type max_element(ForwardRange& rng) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); - return std::max_element(boost::begin(rng), boost::end(rng)); + return boost::first_max_element(boost::begin(rng), boost::end(rng)); } /// \overload @@ -41,7 +41,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type max_element(const ForwardRange& rng) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); - return std::max_element(boost::begin(rng), boost::end(rng)); + return boost::first_max_element(boost::begin(rng), boost::end(rng)); } /// \overload @@ -50,7 +50,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type max_element(ForwardRange& rng, BinaryPredicate pred) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); - return std::max_element(boost::begin(rng), boost::end(rng), pred); + return boost::first_max_element(boost::begin(rng), boost::end(rng), pred); } /// \overload @@ -59,7 +59,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type max_element(const ForwardRange& rng, BinaryPredicate pred) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); - return std::max_element(boost::begin(rng), boost::end(rng), pred); + return boost::first_max_element(boost::begin(rng), boost::end(rng), pred); } // range_return overloads @@ -71,7 +71,7 @@ max_element(ForwardRange& rng) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( - std::max_element(boost::begin(rng), boost::end(rng)), + boost::first_max_element(boost::begin(rng), boost::end(rng)), rng); } @@ -82,7 +82,7 @@ max_element(const ForwardRange& rng) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( - std::max_element(boost::begin(rng), boost::end(rng)), + boost::first_max_element(boost::begin(rng), boost::end(rng)), rng); } @@ -93,7 +93,7 @@ max_element(ForwardRange& rng, BinaryPredicate pred) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( - std::max_element(boost::begin(rng), boost::end(rng), pred), + boost::first_max_element(boost::begin(rng), boost::end(rng), pred), rng); } @@ -104,7 +104,7 @@ max_element(const ForwardRange& rng, BinaryPredicate pred) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( - std::max_element(boost::begin(rng), boost::end(rng), pred), + boost::first_max_element(boost::begin(rng), boost::end(rng), pred), rng); } diff --git a/include/boost/range/algorithm/min_element.hpp b/include/boost/range/algorithm/min_element.hpp index c966b1e..339f56a 100644 --- a/include/boost/range/algorithm/min_element.hpp +++ b/include/boost/range/algorithm/min_element.hpp @@ -9,12 +9,12 @@ #ifndef BOOST_RANGE_ALGORITHM_MIN_ELEMENT_HPP_INCLUDED #define BOOST_RANGE_ALGORITHM_MIN_ELEMENT_HPP_INCLUDED +#include #include #include #include #include #include -#include namespace boost { @@ -32,7 +32,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type min_element(ForwardRange& rng) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); - return std::min_element(boost::begin(rng), boost::end(rng)); + return boost::first_min_element(boost::begin(rng), boost::end(rng)); } /// \overload @@ -41,7 +41,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type min_element(const ForwardRange& rng) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); - return std::min_element(boost::begin(rng), boost::end(rng)); + return boost::first_min_element(boost::begin(rng), boost::end(rng)); } /// \overload @@ -50,7 +50,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type min_element(ForwardRange& rng, BinaryPredicate pred) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); - return std::min_element(boost::begin(rng), boost::end(rng), pred); + return boost::first_min_element(boost::begin(rng), boost::end(rng), pred); } /// \overload @@ -59,7 +59,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type min_element(const ForwardRange& rng, BinaryPredicate pred) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); - return std::min_element(boost::begin(rng), boost::end(rng), pred); + return boost::first_min_element(boost::begin(rng), boost::end(rng), pred); } // range_return overloads @@ -71,7 +71,7 @@ min_element(ForwardRange& rng) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( - std::min_element(boost::begin(rng), boost::end(rng)), + boost::first_min_element(boost::begin(rng), boost::end(rng)), rng); } @@ -82,7 +82,7 @@ min_element(const ForwardRange& rng) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( - std::min_element(boost::begin(rng), boost::end(rng)), + boost::first_min_element(boost::begin(rng), boost::end(rng)), rng); } @@ -93,7 +93,7 @@ min_element(ForwardRange& rng, BinaryPredicate pred) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( - std::min_element(boost::begin(rng), boost::end(rng), pred), + boost::first_min_element(boost::begin(rng), boost::end(rng), pred), rng); } @@ -104,7 +104,7 @@ min_element(const ForwardRange& rng, BinaryPredicate pred) { BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept )); return range_return::pack( - std::min_element(boost::begin(rng), boost::end(rng), pred), + boost::first_min_element(boost::begin(rng), boost::end(rng), pred), rng); } From e4f456d438e5ca7ec653015c9047188a5070527b Mon Sep 17 00:00:00 2001 From: morinmorin Date: Thu, 20 Aug 2015 20:36:19 +0900 Subject: [PATCH 07/39] Fix credit in ticket 5014 testcase --- test/adaptor_test/strided.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/adaptor_test/strided.cpp b/test/adaptor_test/strided.cpp index 6c8475d..46c16fa 100644 --- a/test/adaptor_test/strided.cpp +++ b/test/adaptor_test/strided.cpp @@ -9,7 +9,7 @@ // For more information, see http://www.boost.org/libs/range/ // // The strided_defect_Trac5014 test case is a modified version of a test case -// contributed by Michel Morin as part of the trac ticket. +// contributed by Maxim Yanchenko as part of the trac ticket. // // The deque test case has been removed due to erroneous standard library // implementations causing test failures. From 490ba3fdcdf37badba2913075d9390d80282b1ee Mon Sep 17 00:00:00 2001 From: morinmorin Date: Fri, 21 Aug 2015 21:40:25 +0900 Subject: [PATCH 08/39] Reapply r85400 (this time use Iterator1 instead of Iterator2 as per r85691) and enhance the testcase; fixes ticket 11563. --- include/boost/range/detail/join_iterator.hpp | 8 ++++++-- test/join.cpp | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/boost/range/detail/join_iterator.hpp b/include/boost/range/detail/join_iterator.hpp index 1020ebf..0f47f58 100644 --- a/include/boost/range/detail/join_iterator.hpp +++ b/include/boost/range/detail/join_iterator.hpp @@ -153,8 +153,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 586f05c..300028b 100644 --- a/test/join.cpp +++ b/test/join.cpp @@ -277,6 +277,7 @@ namespace boost std::vector v2; std::vector joined; boost::push_back(joined, join(v1, v2)); + boost::push_back(joined, join(v2, v1)); } namespace trac7376 From 6241dc62aaa496d217266b5463ba39bbf7d4aa9a Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Fri, 11 Sep 2015 15:16:24 -0700 Subject: [PATCH 09/39] Remove use of deprecated macros --- include/boost/range/as_literal.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/range/as_literal.hpp b/include/boost/range/as_literal.hpp index 5d8c436..3bca1a8 100644 --- a/include/boost/range/as_literal.hpp +++ b/include/boost/range/as_literal.hpp @@ -26,7 +26,7 @@ #include -#if !defined(BOOST_NO_CHAR16_T) || !defined(BOOST_NO_CHAR32_T) +#if !defined(BOOST_NO_CXX11_CHAR16_T) || !defined(BOOST_NO_CXX11_CHAR32_T) #include // for std::char_traits #endif @@ -43,14 +43,14 @@ namespace boost return strlen( s ); } -#ifndef BOOST_NO_CHAR16_T +#ifndef BOOST_NO_CXX11_CHAR16_T inline std::size_t length( const char16_t* s ) { return std::char_traits::length( s ); } #endif -#ifndef BOOST_NO_CHAR32_T +#ifndef BOOST_NO_CXX11_CHAR32_T inline std::size_t length( const char32_t* s ) { return std::char_traits::length( s ); @@ -80,7 +80,7 @@ namespace boost return true; } -#ifndef BOOST_NO_CHAR16_T +#ifndef BOOST_NO_CXX11_CHAR16_T inline bool is_char_ptr( char16_t* ) { return true; @@ -92,7 +92,7 @@ namespace boost } #endif -#ifndef BOOST_NO_CHAR32_T +#ifndef BOOST_NO_CXX11_CHAR32_T inline bool is_char_ptr( char32_t* ) { return true; From 9bf860fd30509b5c4ce6ce6b991cd6fe26e39ab7 Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Fri, 18 Sep 2015 09:54:08 +0200 Subject: [PATCH 10/39] Fix compilation boost::detail::iterator_traits was used without including the necessary header file. It's deprecated anyway and only maps to std::iterator_traits. --- include/boost/range/concepts.hpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/boost/range/concepts.hpp b/include/boost/range/concepts.hpp index 3e612a3..87c1e98 100644 --- a/include/boost/range/concepts.hpp +++ b/include/boost/range/concepts.hpp @@ -25,6 +25,8 @@ #include #include +#include + /*! * \file * \brief Concept checks for the Boost Range library. @@ -164,10 +166,10 @@ namespace boost { // work (void)(i++); - BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::reference r1(*i); + BOOST_DEDUCED_TYPENAME std::iterator_traits::reference r1(*i); boost::ignore_unused_variable_warning(r1); - BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::reference r2(*(++i)); + BOOST_DEDUCED_TYPENAME std::iterator_traits::reference r2(*(++i)); boost::ignore_unused_variable_warning(r2); } private: @@ -181,7 +183,7 @@ namespace boost { , DefaultConstructible { #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT - typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::difference_type difference_type; + typedef BOOST_DEDUCED_TYPENAME std::iterator_traits::difference_type difference_type; BOOST_MPL_ASSERT((is_integral)); BOOST_MPL_ASSERT_RELATION(std::numeric_limits::is_signed, ==, true); @@ -200,7 +202,7 @@ namespace boost { // is convertible to reference. Iterator i2(i++); boost::ignore_unused_variable_warning(i2); - BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::reference r(*(i++)); + BOOST_DEDUCED_TYPENAME std::iterator_traits::reference r(*(i++)); boost::ignore_unused_variable_warning(r); } private: From 1a3aeeb3366437b9f2948c97a0e3e77882b7d5d7 Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Tue, 22 Sep 2015 00:51:41 +0200 Subject: [PATCH 11/39] Fix test compilation boost::detail::iterator_traits was used without including the necessary header file. It's deprecated anyway and only maps to std::iterator_traits. Also, utility was missing for std::pair. --- test/iterator_pair.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/iterator_pair.cpp b/test/iterator_pair.cpp index ba13d75..7b615a9 100644 --- a/test/iterator_pair.cpp +++ b/test/iterator_pair.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include void check_iterator_pair() { @@ -39,23 +41,23 @@ void check_iterator_pair() BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value::type, - boost::detail::iterator_traits::value_type>::value )); + std::iterator_traits::value_type>::value )); BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, pair_t::first_type >::value )); BOOST_STATIC_ASSERT(( boost::is_same< boost::range_const_iterator::type, pair_t::first_type >::value )); BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference::type, - boost::detail::iterator_traits::difference_type >::value )); + std::iterator_traits::difference_type >::value )); BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size::type, std::size_t >::value )); BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, pair_t::first_type >::value )); BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, const_pair_t::first_type >::value )); BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value::type, - boost::detail::iterator_traits::value_type>::value )); + std::iterator_traits::value_type>::value )); BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, const_pair_tt::first_type >::value )); // // This behavior is not supported with v2. //BOOST_STATIC_ASSERT(( is_same< range_const_iterator::type, const_pair_tt::first_type >::value )); BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference::type, - boost::detail::iterator_traits::difference_type >::value )); + std::iterator_traits::difference_type >::value )); BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size::type, std::size_t >::value )); BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, const_pair_tt::first_type >::value )); BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator::type, const_pair_tt::first_type >::value )); From 262c0f96b3d0fb9bb9952c3a229a4327bb163efb Mon Sep 17 00:00:00 2001 From: treh Date: Wed, 4 Nov 2015 09:58:15 +0100 Subject: [PATCH 12/39] qualify boost::range_[const|mutable]_iterator otherwise boost::range_detail::range_[const|mutable]_iterator gets accidentily called --- include/boost/range/has_range_iterator.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/range/has_range_iterator.hpp b/include/boost/range/has_range_iterator.hpp index 9eb58b3..88d8664 100644 --- a/include/boost/range/has_range_iterator.hpp +++ b/include/boost/range/has_range_iterator.hpp @@ -37,9 +37,9 @@ namespace boost T, BOOST_DEDUCED_TYPENAME ::boost::enable_if< BOOST_DEDUCED_TYPENAME mpl::eval_if, - has_type::type> >, - has_type > + has_type > >::type >::type > @@ -57,7 +57,7 @@ namespace boost struct has_range_const_iterator_impl< T, BOOST_DEDUCED_TYPENAME ::boost::enable_if< - has_type > + has_type > >::type > : boost::mpl::true_ From 3225aaf82b609a75a24cf5006205e77821e3825b Mon Sep 17 00:00:00 2001 From: Robin Eckert Date: Wed, 4 Nov 2015 19:12:26 +0100 Subject: [PATCH 13/39] add a new range adaptor boost::adaptors::ref_unwrapped The new adaptor is like boost::adaptors::indirected, but for std::reference_wrapper values (instead of pointer). It calls .get() on every value and returns the result. It is useful for range-based iteration of ranges of std::reference_wrapper (or related) types. --- doc/reference/adaptors.qbk | 1 + doc/reference/adaptors/ref_unwrapped.qbk | 32 ++++++ include/boost/range/adaptor/ref_unwrapped.hpp | 102 ++++++++++++++++++ test/Jamfile.v2 | 2 + test/adaptor_test/ref_unwrapped.cpp | 101 +++++++++++++++++ test/adaptor_test/ref_unwrapped_example.cpp | 47 ++++++++ 6 files changed, 285 insertions(+) create mode 100644 doc/reference/adaptors/ref_unwrapped.qbk create mode 100644 include/boost/range/adaptor/ref_unwrapped.hpp create mode 100644 test/adaptor_test/ref_unwrapped.cpp create mode 100644 test/adaptor_test/ref_unwrapped_example.cpp diff --git a/doc/reference/adaptors.qbk b/doc/reference/adaptors.qbk index b3efaee..2cead36 100644 --- a/doc/reference/adaptors.qbk +++ b/doc/reference/adaptors.qbk @@ -172,6 +172,7 @@ rng | boost::adaptors::adaptor_generator [include adaptors/indirected.qbk] [include adaptors/map_keys.qbk] [include adaptors/map_values.qbk] +[include adaptors/ref_unwrapped.qbk] [include adaptors/replaced.qbk] [include adaptors/replaced_if.qbk] [include adaptors/reversed.qbk] diff --git a/doc/reference/adaptors/ref_unwrapped.qbk b/doc/reference/adaptors/ref_unwrapped.qbk new file mode 100644 index 0000000..156ad67 --- /dev/null +++ b/doc/reference/adaptors/ref_unwrapped.qbk @@ -0,0 +1,32 @@ +[/ + Copyright 2015 Robin Eckert + Distributed under 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) +/] +[section:ref_unwrapped ref_unwrapped] + +[table + [[Syntax] [Code]] + [[Pipe] [`rng | boost::adaptors::ref_unwrapped`]] + [[Function] [`boost::adaptors::ref_unwrap(rng)`]] +] + +This adaptor produces a range than applies `.get()` on all values in +the range. It is useful for iterating ranges of +`std::reference_wrapper` values or values using similar semantics. + +The adaptor is C++11 (and above) only. + +* [*Precondition:] The `value_type` of the range has a `.get() const`. +* [*Postcondition:] For all elements `x` in the returned range, `x` is the result of `y.get()` where `y` is the corresponding element in the original range. +* [*Range Category:] __single_pass_range__ +* [*Range Return Type:] `boost::unwrap_ref_range` +* [*Returned Range Category:] The range category of `rng`. + +[section:ref_unwrapped_example ref_unwrapped example] +[import ../../../test/adaptor_test/ref_unwrapped_example.cpp] +[ref_unwrapped_example] +[endsect] + +This would produce the output `123`. +[endsect] diff --git a/include/boost/range/adaptor/ref_unwrapped.hpp b/include/boost/range/adaptor/ref_unwrapped.hpp new file mode 100644 index 0000000..71af483 --- /dev/null +++ b/include/boost/range/adaptor/ref_unwrapped.hpp @@ -0,0 +1,102 @@ +// Boost.Range library +// +// Copyright Robin Eckert 2015. +// Copyright Thorsten Ottosen, Neil Groves 2006 - 2008. 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/ +// + +#ifndef BOOST_RANGE_ADAPTOR_REF_UNWRAPPED_HPP +#define BOOST_RANGE_ADAPTOR_REF_UNWRAPPED_HPP + +#include +#include +#include + +#include + +#if !defined(BOOST_NO_CXX11_DECLTYPE) + +namespace boost +{ + namespace range_detail + { + struct ref_unwrapped_forwarder {}; + + template + struct unwrap_ref + { + typedef BOOST_DEDUCED_TYPENAME + range_reference::type argument_type; + + using result_type = decltype(std::declval().get() ); + + result_type operator()( argument_type &&r ) const + { + return r.get(); + } + }; + + + template + class unwrap_ref_range + : public transformed_range, + SinglePassRange> + { + using base = transformed_range, + SinglePassRange>; + public: + using transform_fn_type = unwrap_ref; + using source_range_type = SinglePassRange; + + unwrap_ref_range(transform_fn_type fn, source_range_type &rng) + : base(fn, rng) + { + } + + unwrap_ref_range(const base &other) : base(other) {} + }; + + template + inline unwrap_ref_range + operator|(SinglePassRange& r, ref_unwrapped_forwarder) + { + BOOST_RANGE_CONCEPT_ASSERT(( + SinglePassRangeConcept)); + + return operator|( r, + boost::adaptors::transformed(unwrap_ref())); + } + + } + + using range_detail::unwrap_ref_range; + + namespace adaptors + { + namespace + { + const range_detail::ref_unwrapped_forwarder ref_unwrapped = + range_detail::ref_unwrapped_forwarder(); + } + + template + inline unwrap_ref_range + ref_unwrap(SinglePassRange& rng) + { + BOOST_RANGE_CONCEPT_ASSERT(( + SinglePassRangeConcept)); + + return unwrap_ref_range( + range_detail::unwrap_ref(), rng ); + } + } // 'adaptors' + +} + +#endif + +#endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 05937c7..f038026 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -59,6 +59,8 @@ test-suite range : [ range-test adaptor_test/indexed ] [ range-test adaptor_test/indirected ] [ range-test adaptor_test/map ] + [ range-test adaptor_test/ref_unwrapped ] + [ range-test adaptor_test/ref_unwrapped_example ] [ range-test adaptor_test/replaced ] [ range-test adaptor_test/replaced_if ] [ range-test adaptor_test/reversed ] diff --git a/test/adaptor_test/ref_unwrapped.cpp b/test/adaptor_test/ref_unwrapped.cpp new file mode 100644 index 0000000..ea190b3 --- /dev/null +++ b/test/adaptor_test/ref_unwrapped.cpp @@ -0,0 +1,101 @@ +// Boost.Range library +// +// Copyright Robin Eckert 2015. 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 + +#define BOOST_TEST_MAIN + +#include +#include + +#include + +#if !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && !defined(BOOST_NO_CXX11_RANGE_BASED_FOR) + +namespace boost +{ + + BOOST_AUTO_TEST_CASE(test_mutable) + { + int one = 1; + int two = 2; + int three = 3; + + std::vector> input_values{one, two, three}; + + const std::vector expected{&one, &two, &three}; + std::vector actual; + + for (auto&& value : input_values | adaptors::ref_unwrapped) + { + actual.push_back(&value); + } + + BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), + expected.end(), + actual.begin(), + actual.end()); + } + + BOOST_AUTO_TEST_CASE(test_const_range) + { + int one = 1; + int two = 2; + int three = 3; + + const std::vector> input_values{one, two, three}; + + const std::vector expected{&one, &two, &three}; + std::vector actual; + + for (auto&& value : input_values | adaptors::ref_unwrapped) + { + actual.push_back(&value); + } + + BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), + expected.end(), + actual.begin(), + actual.end()); + } + + BOOST_AUTO_TEST_CASE(test_const_reference) + { + const int one = 1; + const int two = 2; + const int three = 3; + + const std::vector> input_values{one, two, three}; + + const std::vector expected{&one, &two, &three}; + std::vector actual; + + for (auto&& value : input_values | adaptors::ref_unwrapped) + { + actual.push_back(&value); + } + + BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), + expected.end(), + actual.begin(), + actual.end()); + } + + +} + +#else + +BOOST_AUTO_TEST_CASE(empty) +{ + // C++11 only +} + +#endif diff --git a/test/adaptor_test/ref_unwrapped_example.cpp b/test/adaptor_test/ref_unwrapped_example.cpp new file mode 100644 index 0000000..ab3e401 --- /dev/null +++ b/test/adaptor_test/ref_unwrapped_example.cpp @@ -0,0 +1,47 @@ +// Boost.Range library +// +// Copyright Robin Eckert 2015. 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/ +// +//[ref_unwrapped_example +#include +#include +#include + +struct example +{ + int value; +}; + +int main(int argc, const char* argv[]) +{ +//<- +#if !defined(BOOST_NO_CXX11_DECLTYPE) \ + && !defined(BOOST_NO_CXX11_RANGE_BASED_FOR) \ + && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX) \ + && !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) +//-> + using boost::adaptors::ref_unwrapped; + + example one{1}; + example two{2}; + example three{3}; + + std::vector > input{one, two, three}; + + for (auto&& entry : input | ref_unwrapped) + { + std::cout << entry.value; + } + + return 0; +//<- +#endif +//-> +} +//] From 7ca999c66298c86c2ec1f61709fce119e32f36b5 Mon Sep 17 00:00:00 2001 From: rydotyosh Date: Sat, 14 Nov 2015 15:41:48 +0900 Subject: [PATCH 14/39] [range] fixed minor typo in docs --- doc/headers.qbk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/headers.qbk b/doc/headers.qbk index 3107018..2e5ae02 100644 --- a/doc/headers.qbk +++ b/doc/headers.qbk @@ -46,7 +46,7 @@ [[``] [__range_adaptors_copied__]] [[``] [__range_adaptors_filtered__]] [[``] [__range_adaptors_indexed__]] - [[``] [__range_adaptors_indirected__]] [[``] [__range_adaptors_map_keys__ __range_adaptors_map_values__]] [[``] [__range_adaptors_replaced__]] [[``] [__range_adaptors_replaced_if__]] From bb438874301e0b3b38d8c47c359975d4572eb5ee Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sun, 17 Jan 2016 11:40:55 +0100 Subject: [PATCH 15/39] irange: introduce one-parameter variant of irange this simplifies the use of boost::irange, as boost::irange( 0, foo ); may compile or not depending on the platform-specific integer type of foo, requiring an explicit cast of 0 to decltype(foo). --- doc/reference/ranges/irange.qbk | 7 +++-- include/boost/range/irange.hpp | 11 +++++-- test/irange.cpp | 52 ++++++++++++++++++++++++++++----- 3 files changed, 59 insertions(+), 11 deletions(-) diff --git a/doc/reference/ranges/irange.qbk b/doc/reference/ranges/irange.qbk index 6e59cb1..1d4ae7e 100644 --- a/doc/reference/ranges/irange.qbk +++ b/doc/reference/ranges/irange.qbk @@ -10,7 +10,11 @@ `` template iterator_range< range_detail::integer_iterator > -irange(Integer first, Integer last); +irange(Integer last); + +template +iterator_range< range_detail::integer_iterator > +irange(Integer first, Integer last); template iterator_range< range_detail::integer_iterator_with_step > @@ -37,4 +41,3 @@ Defined in the header file `boost/range/irange.hpp` Constant. Since this function generates a new range the most significant performance cost is incurred through the iteration of the generated range. [endsect] - diff --git a/include/boost/range/irange.hpp b/include/boost/range/irange.hpp index b1a1240..7d5fee5 100644 --- a/include/boost/range/irange.hpp +++ b/include/boost/range/irange.hpp @@ -217,7 +217,7 @@ namespace boost { BOOST_ASSERT( step_size != 0 ); BOOST_ASSERT( (step_size > 0) ? (last >= first) : (last <= first) ); - + typedef typename range_detail::integer_iterator_with_step iterator_t; const std::ptrdiff_t sz = static_cast(step_size >= 0 ? step_size : -step_size); @@ -225,12 +225,19 @@ namespace boost const Integer f = step_size >= 0 ? first : last; const std::ptrdiff_t num_steps = (l - f) / sz + ((l - f) % sz ? 1 : 0); BOOST_ASSERT(num_steps >= 0); - + return strided_integer_range( iterator_t(first, 0, step_size), iterator_t(first, num_steps, step_size)); } + template + integer_range + irange(Integer last) + { + return integer_range(static_cast(0), last); + } + } // namespace boost #endif // include guard diff --git a/test/irange.cpp b/test/irange.cpp index 659401b..7e1a564 100644 --- a/test/irange.cpp +++ b/test/irange.cpp @@ -18,6 +18,23 @@ namespace boost { + // Test an integer range with a step size of 1. + template + void test_irange_impl(Integer last) + { + std::vector reference; + for (Integer i = static_cast(0); i < last; ++i) + { + reference.push_back(i); + } + + std::vector test; + boost::push_back(test, boost::irange(last)); + + BOOST_CHECK_EQUAL_COLLECTIONS( test.begin(), test.end(), + reference.begin(), reference.end() ); + } + // Test an integer range with a step size of 1. template void test_irange_impl(Integer first, Integer last) @@ -34,36 +51,52 @@ namespace boost BOOST_CHECK_EQUAL_COLLECTIONS( test.begin(), test.end(), reference.begin(), reference.end() ); } - + // Test an integer range with a runtime specified step size. template void test_irange_impl(IntegerInput first, IntegerInput last, int step) { BOOST_ASSERT( step != 0 ); - + // Skip tests that have negative values if the type is // unsigned if ((static_cast(static_cast(first)) != first) || (static_cast(static_cast(last)) != last)) return; - + std::vector reference; const std::ptrdiff_t first_p = static_cast(first); const std::ptrdiff_t last_p = static_cast(last); const std::ptrdiff_t step_p = static_cast(step); - for (std::ptrdiff_t current_value = first_p; + 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 test; boost::push_back(test, boost::irange(first, last, step)); - + BOOST_CHECK_EQUAL_COLLECTIONS( test.begin(), test.end(), reference.begin(), reference.end() ); } + // Test driver function that for an integer range [first, last) + // drives the test implementation through various integer + // types. + void test_irange(int last) + { + test_irange_impl(last); + test_irange_impl(last); + test_irange_impl(last); + test_irange_impl(last); + test_irange_impl(last); + test_irange_impl(last); + test_irange_impl(last); + test_irange_impl(last); + } + + // Test driver function that for an integer range [first, last) // drives the test implementation through various integer // types. @@ -102,6 +135,11 @@ namespace boost // number of implementation branches. void irange_unit_test() { + // Test the single-step version of irange(last) + test_irange(0); + test_irange(1); + test_irange(10); + // Test the single-step version of irange(first, last) test_irange(0, 0); test_irange(0, 1); @@ -124,14 +162,14 @@ namespace boost test_irange(9, -9, -2); test_irange(10, 20, 5); test_irange(20, 10, -5); - + test_irange(0, 0, 3); test_irange(0, 1, 3); test_irange(0, 2, 3); test_irange(0, 3, 3); test_irange(0, 4, 3); test_irange(0, 10, 3); - + test_irange(0, 0, -3); test_irange(0, -1, -3); test_irange(0, -2, -3); From 4ce15f9b52afeed5919693de191b533c5b0f9861 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Sun, 24 Jan 2016 22:51:19 +0300 Subject: [PATCH 16/39] Added BOOST_CONSTEXPR for begin()/end() --- include/boost/range/begin.hpp | 14 +++++++------- include/boost/range/detail/begin.hpp | 8 ++++---- include/boost/range/detail/end.hpp | 8 ++++---- .../boost/range/detail/implementation_help.hpp | 4 ++-- include/boost/range/end.hpp | 16 ++++++++-------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/boost/range/begin.hpp b/include/boost/range/begin.hpp index ba5a73b..0d7d3db 100644 --- a/include/boost/range/begin.hpp +++ b/include/boost/range/begin.hpp @@ -36,7 +36,7 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename C > - inline BOOST_DEDUCED_TYPENAME range_iterator::type + BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator::type range_begin( C& c ) { // @@ -52,13 +52,13 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename Iterator > - inline Iterator range_begin( const std::pair& p ) + BOOST_CONSTEXPR inline Iterator range_begin( const std::pair& p ) { return p.first; } template< typename Iterator > - inline Iterator range_begin( std::pair& p ) + BOOST_CONSTEXPR inline Iterator range_begin( std::pair& p ) { return p.first; } @@ -71,13 +71,13 @@ namespace range_detail // May this be discarded? Or is it needed for bad compilers? // template< typename T, std::size_t sz > - inline const T* range_begin( const T (&a)[sz] ) + BOOST_CONSTEXPR inline const T* range_begin( const T (&a)[sz] ) BOOST_NOEXCEPT { return a; } template< typename T, std::size_t sz > - inline T* range_begin( T (&a)[sz] ) + BOOST_CONSTEXPR inline T* range_begin( T (&a)[sz] ) BOOST_NOEXCEPT { return a; } @@ -94,7 +94,7 @@ namespace range_adl_barrier { template< class T > -inline BOOST_DEDUCED_TYPENAME range_iterator::type begin( T& r ) +BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator::type begin( T& r ) { #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) using namespace range_detail; @@ -103,7 +103,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type begin( T& r ) } template< class T > -inline BOOST_DEDUCED_TYPENAME range_iterator::type begin( const T& r ) +BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator::type begin( const T& r ) { #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) using namespace range_detail; diff --git a/include/boost/range/detail/begin.hpp b/include/boost/range/detail/begin.hpp index 1d9390f..efadaa6 100644 --- a/include/boost/range/detail/begin.hpp +++ b/include/boost/range/detail/begin.hpp @@ -32,7 +32,7 @@ namespace boost struct range_begin { template< typename C > - static BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type fun( C& c ) + BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type fun( C& c ) { return c.begin(); }; @@ -46,7 +46,7 @@ namespace boost struct range_begin { template< typename P > - static BOOST_RANGE_DEDUCED_TYPENAME range_iterator

::type fun( const P& p ) + BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_iterator

::type fun( const P& p ) { return p.first; } @@ -60,7 +60,7 @@ namespace boost struct range_begin { template - static BOOST_RANGE_DEDUCED_TYPENAME range_value::type* fun(T& t) + BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_value::type* fun(T& t) { return t; } @@ -71,7 +71,7 @@ namespace boost namespace range_adl_barrier { template< typename C > - inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type + BOOST_CONSTEXPR inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type begin( C& c ) { return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range::type >::fun( c ); diff --git a/include/boost/range/detail/end.hpp b/include/boost/range/detail/end.hpp index f2f7178..7622921 100644 --- a/include/boost/range/detail/end.hpp +++ b/include/boost/range/detail/end.hpp @@ -33,7 +33,7 @@ namespace boost struct range_end { template< typename C > - static BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type + BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type fun( C& c ) { return c.end(); @@ -48,7 +48,7 @@ namespace boost struct range_end { template< typename P > - static BOOST_RANGE_DEDUCED_TYPENAME range_iterator

::type + BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_iterator

::type fun( const P& p ) { return p.second; @@ -63,7 +63,7 @@ namespace boost struct range_end { template - static BOOST_RANGE_DEDUCED_TYPENAME remove_extent::type* fun(T& t) + BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME remove_extent::type* fun(T& t) { return t + remove_extent::size; } @@ -74,7 +74,7 @@ namespace boost namespace range_adl_barrier { template< typename C > - inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type + BOOST_CONSTEXPR inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator::type end( C& c ) { return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range::type >::fun( c ); diff --git a/include/boost/range/detail/implementation_help.hpp b/include/boost/range/detail/implementation_help.hpp index f35953f..59a3ade 100644 --- a/include/boost/range/detail/implementation_help.hpp +++ b/include/boost/range/detail/implementation_help.hpp @@ -60,13 +60,13 @@ namespace boost } template< class T, std::size_t sz > - inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz] ) + BOOST_CONSTEXPR inline T* array_end( T BOOST_RANGE_ARRAY_REF()[sz] ) BOOST_NOEXCEPT { return boost_range_array + sz; } template< class T, std::size_t sz > - inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] ) + BOOST_CONSTEXPR inline const T* array_end( const T BOOST_RANGE_ARRAY_REF()[sz] ) BOOST_NOEXCEPT { return boost_range_array + sz; } diff --git a/include/boost/range/end.hpp b/include/boost/range/end.hpp index f2a3337..588495c 100644 --- a/include/boost/range/end.hpp +++ b/include/boost/range/end.hpp @@ -37,7 +37,7 @@ namespace range_detail // primary template ////////////////////////////////////////////////////////////////////// template< typename C > - inline BOOST_DEDUCED_TYPENAME range_iterator::type + BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator::type range_end( C& c ) { // @@ -53,13 +53,13 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename Iterator > - inline Iterator range_end( const std::pair& p ) + BOOST_CONSTEXPR inline Iterator range_end( const std::pair& p ) { return p.second; } template< typename Iterator > - inline Iterator range_end( std::pair& p ) + BOOST_CONSTEXPR inline Iterator range_end( std::pair& p ) { return p.second; } @@ -69,13 +69,13 @@ namespace range_detail ////////////////////////////////////////////////////////////////////// template< typename T, std::size_t sz > - inline const T* range_end( const T (&a)[sz] ) + BOOST_CONSTEXPR inline const T* range_end( const T (&a)[sz] ) BOOST_NOEXCEPT { return range_detail::array_end( a ); } template< typename T, std::size_t sz > - inline T* range_end( T (&a)[sz] ) + BOOST_CONSTEXPR inline T* range_end( T (&a)[sz] ) BOOST_NOEXCEPT { return range_detail::array_end( a ); } @@ -88,7 +88,7 @@ namespace range_adl_barrier { template< class T > -inline BOOST_DEDUCED_TYPENAME range_iterator::type end( T& r ) +BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator::type end( T& r ) { #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) using namespace range_detail; @@ -97,7 +97,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator::type end( T& r ) } template< class T > -inline BOOST_DEDUCED_TYPENAME range_iterator::type end( const T& r ) +BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator::type end( const T& r ) { #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) using namespace range_detail; @@ -115,7 +115,7 @@ namespace boost namespace range_adl_barrier { template< class T > - inline BOOST_DEDUCED_TYPENAME range_iterator::type + BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator::type const_end( const T& r ) { return boost::range_adl_barrier::end( r ); From 283b8beddcdfbdcbdc0589ab599201f942193f8d Mon Sep 17 00:00:00 2001 From: mateuszlewko Date: Sat, 9 Apr 2016 19:32:22 +0200 Subject: [PATCH 17/39] Update irange.hpp Added: irange(int last), irange(int first, int last) --- include/boost/range/irange.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/boost/range/irange.hpp b/include/boost/range/irange.hpp index b1a1240..3c62d62 100644 --- a/include/boost/range/irange.hpp +++ b/include/boost/range/irange.hpp @@ -203,6 +203,22 @@ namespace boost } }; + template + integer_range + irange(int last) + { + BOOST_ASSERT( 0 <= last ); + return integer_range(0, last); + } + + template + integer_range + irange(int first, int last) + { + BOOST_ASSERT( first <= last ); + return integer_range(first, last); + } + template integer_range irange(Integer first, Integer last) From e48b9c38e74bcf6028be9defd62d3ecf3ebf7a0c Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Fri, 7 Oct 2016 23:07:36 -0500 Subject: [PATCH 18/39] Add, and update, documentation build targets. --- doc/Jamfile.v2 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 82a8d7f..c507180 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -28,3 +28,8 @@ boostbook quickbook pdf:img.src.path=$(images_location)/ ; +############################################################################### +alias boostdoc ; +explicit boostdoc ; +alias boostrelease : quickbook ; +explicit boostrelease ; From 1b4f8100efab5f3b7d9886c3bdfe309b2c500f4e Mon Sep 17 00:00:00 2001 From: Jean-Philippe DUFRAIGNE Date: Sun, 23 Oct 2016 23:27:31 +0100 Subject: [PATCH 19/39] Allow iterator copy for lambda in transformed and filtered Lambda has no default constructor nor a copy or move assignment. range\test\adaptors.cpp is checking that produced ranges are copiable, but it is not doing so the for lambda, or lambda like objects. default_constructible_unary_fn uses an optional for default construction. I extended it to use its emplace facility to copy assign non copy assignable types. (see boost::optional 'Type Requierment': 'If T is not MoveAssignable, it is still possible to reset the value of optional using function emplace():') --- .../detail/default_constructible_unary_fn.hpp | 17 ++++++ test/adaptor_test/filtered.cpp | 52 ++++++++++++++++--- test/adaptor_test/transformed.cpp | 42 +++++++++++++-- 3 files changed, 101 insertions(+), 10 deletions(-) diff --git a/include/boost/range/detail/default_constructible_unary_fn.hpp b/include/boost/range/detail/default_constructible_unary_fn.hpp index 374ddda..9729e3c 100644 --- a/include/boost/range/detail/default_constructible_unary_fn.hpp +++ b/include/boost/range/detail/default_constructible_unary_fn.hpp @@ -32,6 +32,23 @@ public: : m_impl(source) { } + default_constructible_unary_fn_wrapper(const default_constructible_unary_fn_wrapper& source) + : m_impl(source.m_impl) + { + } + default_constructible_unary_fn_wrapper& operator=(const default_constructible_unary_fn_wrapper& source) + { + if (source.m_impl) + { + // Lambda are not copy/move assignable. + m_impl.emplace(*source.m_impl); + } + else + { + m_impl.reset(); + } + return *this; + } template R operator()(const Arg& arg) const { diff --git a/test/adaptor_test/filtered.cpp b/test/adaptor_test/filtered.cpp index 17a457f..be34872 100644 --- a/test/adaptor_test/filtered.cpp +++ b/test/adaptor_test/filtered.cpp @@ -51,6 +51,23 @@ namespace boost bool operator()( IntegerT x ) const { return x % 2 != 0; } }; + struct lambda_init + { + }; + + struct lambda + { + lambda(const lambda_init& init) {} + lambda(const lambda& rhs) {} + + template< class T1 > + bool operator()(T1) const { return false; } + + private: + lambda() {} + lambda& operator=(const lambda& rhs) { return *this; } + }; + template< class Container, class Pred > void filtered_test_impl( Container& c, Pred pred ) { @@ -86,32 +103,53 @@ namespace boost test_result2.end() ); } + template< class Rng > + void check_copy_assign(Rng r) + { + Rng r2 = r; + r2 = r; + } + template< class Container, class Pred > + void filtered_range_copy_assign(Container& c, Pred pred) + { + using namespace boost::adaptors; + check_copy_assign(c | filtered(pred)); + check_copy_assign(adaptors::filter(c, pred)); + } + + template< class Container, class Pred, class PredInit > void filtered_test_impl() { using namespace boost::assign; Container c; + PredInit init; + Pred pred(init); // test empty container - filtered_test_impl(c, Pred()); + filtered_test_impl(c, pred); // test one element c += 1; - filtered_test_impl(c, Pred()); + filtered_test_impl(c, pred); // test many elements c += 1,2,2,2,3,4,4,4,4,5,6,7,8,9,9; - filtered_test_impl(c, Pred()); + filtered_test_impl(c, pred); + + // test the range and iterator are copy assignable + filtered_range_copy_assign(c, pred); } template< class Container > void filtered_test_all_predicates() { - filtered_test_impl< Container, always_false_pred >(); - filtered_test_impl< Container, always_true_pred >(); - filtered_test_impl< Container, is_odd >(); - filtered_test_impl< Container, is_even >(); + filtered_test_impl< Container, always_false_pred, always_false_pred >(); + filtered_test_impl< Container, always_true_pred, always_true_pred >(); + filtered_test_impl< Container, is_odd, is_odd >(); + filtered_test_impl< Container, is_even, is_even >(); + filtered_test_impl< Container, lambda, lambda_init >(); } void ticket_10988_single_pass() diff --git a/test/adaptor_test/transformed.cpp b/test/adaptor_test/transformed.cpp index adadafc..9146f84 100644 --- a/test/adaptor_test/transformed.cpp +++ b/test/adaptor_test/transformed.cpp @@ -38,6 +38,22 @@ namespace boost int operator()(int x) const { return x / 2; } }; + struct lambda_init + { + }; + + struct lambda + { + lambda(const lambda_init& init) {} + lambda(const lambda& rhs) {} + + int operator()(int x) const { return x + 1; } + + private: + lambda() {} + lambda& operator=(const lambda& rhs) { return *this; } + }; + template< class Container, class TransformFn > void transformed_test_impl_core( Container& c, TransformFn fn ) { @@ -59,13 +75,29 @@ namespace boost test_result2.begin(), test_result2.end() ); } + template< class Rng > + void check_copy_assign(Rng r) + { + Rng r2 = r; + r2 = r; + } + template< class Container, class TransformFn > + void transformed_range_copy_assign(Container& c, TransformFn fn) + { + using namespace boost::adaptors; + check_copy_assign(c | transformed(fn)); + check_copy_assign(adaptors::transform(c, fn)); + } + + template< class Container, class TransformFn, class TransformFnInit > void transformed_test_fn_impl() { using namespace boost::assign; Container c; - TransformFn fn; + TransformFnInit init; + TransformFn fn( init ); // Test empty transformed_test_impl_core(c, fn); @@ -77,13 +109,17 @@ namespace boost // Test many elements c += 1,1,1,2,2,2,2,2,3,4,5,6,7,8,9; transformed_test_impl_core(c, fn); + + // test the range and iterator are copy assignable + transformed_range_copy_assign(c, fn); } template< class Container > void transformed_test_impl() { - transformed_test_fn_impl< Container, double_x >(); - transformed_test_fn_impl< Container, halve_x >(); + transformed_test_fn_impl< Container, double_x, double_x >(); + transformed_test_fn_impl< Container, halve_x, halve_x >(); + transformed_test_fn_impl< Container, lambda, lambda_init >(); } void transformed_test() From 9e5680b5904c5bfcd6d1b5a061a6b821bfff7d13 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Fri, 18 Nov 2016 11:50:32 -0800 Subject: [PATCH 20/39] Don't assume that because type `T` is a range that `const T` is also a range. size_type erroneously dispatches to detail::size_type_. That breaks for types that have non-const begin/end but that don't have const begin/end. The range-v3 library has such types. --- include/boost/range/size_type.hpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/boost/range/size_type.hpp b/include/boost/range/size_type.hpp index f41c321..0a2ea81 100644 --- a/include/boost/range/size_type.hpp +++ b/include/boost/range/size_type.hpp @@ -83,11 +83,6 @@ namespace boost detail::range_size { }; - template< class T > - struct range_size : - detail::range_size - { }; - } // namespace boost From 910fc7bf822ed9bdbfff83340d9258c8932335b6 Mon Sep 17 00:00:00 2001 From: Eric Niebler Date: Wed, 23 Nov 2016 14:47:42 -0800 Subject: [PATCH 21/39] Qualify call to boost::size to avoid ambiguity with std::size --- test/iterator_range.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/iterator_range.cpp b/test/iterator_range.cpp index 97c966a..9bbcff2 100644 --- a/test/iterator_range.cpp +++ b/test/iterator_range.cpp @@ -59,8 +59,8 @@ void check_iterator_range() BOOST_CHECK( false ); //#endif - BOOST_CHECK_EQUAL( r.size(), size( r ) ); - BOOST_CHECK_EQUAL( r2.size(), size( r2 ) ); + BOOST_CHECK_EQUAL( r.size(), boost::size( r ) ); + BOOST_CHECK_EQUAL( r2.size(), boost::size( r2 ) ); BOOST_CHECK_EQUAL( std::distance( r.begin(), r.end() ), std::distance( boost::begin( r2 ), boost::end( r2 ) ) ); From 7b89c747d614f56e3defdc4421054627c4435b1d Mon Sep 17 00:00:00 2001 From: Tim Wynants Date: Thu, 12 Jan 2017 17:45:31 +0100 Subject: [PATCH 22/39] Ticket 12754 - operator| overload for boost::range_details::replace_holder is not SFINEA friendly include\boost\range\adaptor\replaced.hpp Make sure that the overload resolution doesn't choke on the value type factory when its considers the overload --- include/boost/range/adaptor/replaced.hpp | 30 ++++++++++-------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/include/boost/range/adaptor/replaced.hpp b/include/boost/range/adaptor/replaced.hpp index 1950b82..761ba20 100644 --- a/include/boost/range/adaptor/replaced.hpp +++ b/include/boost/range/adaptor/replaced.hpp @@ -101,12 +101,10 @@ namespace boost void operator=(const replace_holder&); }; - template< class SinglePassRange > + template< class SinglePassRange, + class RangeValueType = BOOST_DEDUCED_TYPENAME range_value::type> inline replaced_range - operator|( - SinglePassRange& r, - const replace_holder< - BOOST_DEDUCED_TYPENAME range_value::type>& f ) + operator|(SinglePassRange& r, const replace_holder& f) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept)); @@ -114,12 +112,10 @@ namespace boost return replaced_range(r, f.val1, f.val2); } - template< class SinglePassRange > + template< class SinglePassRange, + class RangeValueType = BOOST_DEDUCED_TYPENAME range_value::type> inline replaced_range - operator|( - const SinglePassRange& r, - const replace_holder< - BOOST_DEDUCED_TYPENAME range_value::type>& f) + operator|(const SinglePassRange& r, const replace_holder& f) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept)); @@ -139,11 +135,10 @@ namespace boost range_detail::forwarder2(); } - template + template< class SinglePassRange, + class RangeValueType = BOOST_DEDUCED_TYPENAME range_value::type> inline replaced_range - replace(SinglePassRange& rng, - BOOST_DEDUCED_TYPENAME range_value::type from, - BOOST_DEDUCED_TYPENAME range_value::type to) + replace(SinglePassRange& rng, RangeValueType from, RangeValueType to) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept)); @@ -151,11 +146,10 @@ namespace boost return replaced_range(rng, from, to); } - template + template< class SinglePassRange, + class RangeValueType = BOOST_DEDUCED_TYPENAME range_value::type> inline replaced_range - replace(const SinglePassRange& rng, - BOOST_DEDUCED_TYPENAME range_value::type from, - BOOST_DEDUCED_TYPENAME range_value::type to) + replace(const SinglePassRange& rng, RangeValueType from, RangeValueType to) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept)); From e476e1900a20d9474fb261b41e0ea5b0979435bb Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Wed, 3 May 2017 10:18:25 +0300 Subject: [PATCH 23/39] Fix broken link in overview --- doc/concepts.qbk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/concepts.qbk b/doc/concepts.qbk index f379e18..e0b5f41 100644 --- a/doc/concepts.qbk +++ b/doc/concepts.qbk @@ -7,7 +7,7 @@ [section Overview] -A Range is a [*/concept/] similar to the STL [@http://www.sgi.com/Technology/STL/Container.html Container] concept. A Range provides iterators for accessing a half-open range `[first,one_past_last)` of elements and provides information about the number of elements in the Range. However, a Range has fewer requirements than a Container. +A Range is a [*/concept/] similar to the STL [@http://www.sgi.com/tech/stl/Container.html Container] concept. A Range provides iterators for accessing a half-open range `[first,one_past_last)` of elements and provides information about the number of elements in the Range. However, a Range has fewer requirements than a Container. The motivation for the Range concept is that there are many useful Container-like types that do not meet the full requirements of Container, and many algorithms that can be written with this reduced set of requirements. In particular, a Range does not necessarily From 23e5801e2a590084ae31ce027c3498f97a8d71d1 Mon Sep 17 00:00:00 2001 From: Daniela Engert Date: Thu, 4 May 2017 18:36:40 +0200 Subject: [PATCH 24/39] Conditionally replace deprecated/removed C++98 function adapters and std::random_shuffle by equivalents. Signed-off-by: Daniela Engert --- .../boost/range/algorithm/random_shuffle.hpp | 81 ++++++++++++++++++- test/ticket_5486.cpp | 6 +- 2 files changed, 81 insertions(+), 6 deletions(-) diff --git a/include/boost/range/algorithm/random_shuffle.hpp b/include/boost/range/algorithm/random_shuffle.hpp index 95bbd97..2475173 100644 --- a/include/boost/range/algorithm/random_shuffle.hpp +++ b/include/boost/range/algorithm/random_shuffle.hpp @@ -14,12 +14,85 @@ #include #include #include +#ifdef BOOST_NO_CXX98_RANDOM_SHUFFLE +#include +#endif namespace boost { namespace range { + namespace detail + { +#ifdef BOOST_NO_CXX98_RANDOM_SHUFFLE + +// wrap std::rand as UniformRandomBitGenerator +struct wrap_rand +{ + typedef unsigned int result_type; + + static result_type (min)() + { + return 0; + } + + static result_type (max)() + { + return RAND_MAX; + } + + result_type operator()() + { + return std::rand(); + } +}; + +template< class RandomIt > +inline void random_shuffle(RandomIt first, RandomIt last) +{ + std::shuffle(first, last, wrap_rand()); +} + +// wrap Generator as UniformRandomBitGenerator +template< class Generator > +struct wrap_generator +{ + typedef unsigned int result_type; + static const int max_arg = ((0u - 1u) >> 2) + 1; + Generator& g; + + wrap_generator(Generator& gen) : g(gen) {} + + static result_type (min)() + { + return 0; + } + + static result_type (max)() + { + return max_arg - 1; + } + + result_type operator()() + { + return static_cast(g(max_arg)); + } +}; + +template< class RandomIt, class Generator > +inline void random_shuffle(RandomIt first, RandomIt last, Generator& gen) +{ + std::shuffle(first, last, wrap_generator< Generator >(gen)); +} + +#else + +using std::random_shuffle; + +#endif + } // namespace detail + /// \brief template function random_shuffle /// /// range-based version of the random_shuffle std algorithm @@ -30,7 +103,7 @@ template inline RandomAccessRange& random_shuffle(RandomAccessRange& rng) { BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); - std::random_shuffle(boost::begin(rng), boost::end(rng)); + detail::random_shuffle(boost::begin(rng), boost::end(rng)); return rng; } @@ -39,7 +112,7 @@ template inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng) { BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); - std::random_shuffle(boost::begin(rng), boost::end(rng)); + detail::random_shuffle(boost::begin(rng), boost::end(rng)); return rng; } @@ -48,7 +121,7 @@ template inline RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen) { BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); - std::random_shuffle(boost::begin(rng), boost::end(rng), gen); + detail::random_shuffle(boost::begin(rng), boost::end(rng), gen); return rng; } @@ -57,7 +130,7 @@ template inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen) { BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept )); - std::random_shuffle(boost::begin(rng), boost::end(rng), gen); + detail::random_shuffle(boost::begin(rng), boost::end(rng), gen); return rng; } diff --git a/test/ticket_5486.cpp b/test/ticket_5486.cpp index 3a6bf4b..94d8dd4 100644 --- a/test/ticket_5486.cpp +++ b/test/ticket_5486.cpp @@ -14,7 +14,6 @@ #include #include -#include #include namespace boost @@ -22,9 +21,12 @@ namespace boost namespace { class TestTicket5486Pred - : public std::binary_function { public: + typedef int first_argument_type; + typedef int second_argument_type; + typedef bool result_type; + explicit TestTicket5486Pred(int x) {} bool operator()(int,int) const { return true; } private: From 69409ed63a9e103e3e487a8ec0a2fd0e24ab9523 Mon Sep 17 00:00:00 2001 From: morinmorin Date: Fri, 30 Jun 2017 20:02:53 +0900 Subject: [PATCH 25/39] Make boost::distance traversal-category-aware (and constexpr in C++14) --- include/boost/range/distance.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/boost/range/distance.hpp b/include/boost/range/distance.hpp index 075f2d1..8dcf05b 100644 --- a/include/boost/range/distance.hpp +++ b/include/boost/range/distance.hpp @@ -15,18 +15,19 @@ # pragma once #endif +#include #include #include #include -namespace boost +namespace boost { template< class T > - inline BOOST_DEDUCED_TYPENAME range_difference::type + inline BOOST_CXX14_CONSTEXPR BOOST_DEDUCED_TYPENAME range_difference::type distance( const T& r ) { - return std::distance( boost::begin( r ), boost::end( r ) ); + return boost::distance( boost::begin( r ), boost::end( r ) ); } } // namespace 'boost' From 93eb91e63e72f7548500cf935be467e4a7512c2f Mon Sep 17 00:00:00 2001 From: morinmorin Date: Wed, 12 Jul 2017 22:06:58 +0900 Subject: [PATCH 26/39] Fix breakage in replaced adaptor for C++03 --- include/boost/range/adaptor/replaced.hpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/include/boost/range/adaptor/replaced.hpp b/include/boost/range/adaptor/replaced.hpp index 761ba20..42eb52a 100644 --- a/include/boost/range/adaptor/replaced.hpp +++ b/include/boost/range/adaptor/replaced.hpp @@ -101,10 +101,9 @@ namespace boost void operator=(const replace_holder&); }; - template< class SinglePassRange, - class RangeValueType = BOOST_DEDUCED_TYPENAME range_value::type> + template< class SinglePassRange, class Value > inline replaced_range - operator|(SinglePassRange& r, const replace_holder& f) + operator|(SinglePassRange& r, const replace_holder& f) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept)); @@ -112,10 +111,9 @@ namespace boost return replaced_range(r, f.val1, f.val2); } - template< class SinglePassRange, - class RangeValueType = BOOST_DEDUCED_TYPENAME range_value::type> + template< class SinglePassRange, class Value > inline replaced_range - operator|(const SinglePassRange& r, const replace_holder& f) + operator|(const SinglePassRange& r, const replace_holder& f) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept)); @@ -135,10 +133,9 @@ namespace boost range_detail::forwarder2(); } - template< class SinglePassRange, - class RangeValueType = BOOST_DEDUCED_TYPENAME range_value::type> + template< class SinglePassRange, class Value > inline replaced_range - replace(SinglePassRange& rng, RangeValueType from, RangeValueType to) + replace(SinglePassRange& rng, Value from, Value to) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept)); @@ -146,10 +143,9 @@ namespace boost return replaced_range(rng, from, to); } - template< class SinglePassRange, - class RangeValueType = BOOST_DEDUCED_TYPENAME range_value::type> + template< class SinglePassRange, class Value > inline replaced_range - replace(const SinglePassRange& rng, RangeValueType from, RangeValueType to) + replace(const SinglePassRange& rng, Value from, Value to) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept)); From 93513a3801c55ed1e15a9da623ba9f1429ac8e80 Mon Sep 17 00:00:00 2001 From: morinmorin Date: Wed, 12 Jul 2017 22:08:22 +0900 Subject: [PATCH 27/39] Make `rng | replaced_if` consistent with `rng | replaced` --- include/boost/range/adaptor/replaced_if.hpp | 28 ++++++--------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/include/boost/range/adaptor/replaced_if.hpp b/include/boost/range/adaptor/replaced_if.hpp index e425e7d..83d3ec8 100644 --- a/include/boost/range/adaptor/replaced_if.hpp +++ b/include/boost/range/adaptor/replaced_if.hpp @@ -103,13 +103,9 @@ namespace boost T m_to; }; - template< class Pred, class SinglePassRange > + template< class Pred, class SinglePassRange, class Value > inline replaced_if_range - operator|( - SinglePassRange& r, - const replace_if_holder< - Pred, - BOOST_DEDUCED_TYPENAME range_value::type>& f) + operator|(SinglePassRange& r, const replace_if_holder& f) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept)); @@ -118,13 +114,9 @@ namespace boost r, f.pred(), f.to()); } - template< class Pred, class SinglePassRange > + template< class Pred, class SinglePassRange, class Value > inline replaced_if_range - operator|( - const SinglePassRange& r, - const replace_if_holder< - Pred, - BOOST_DEDUCED_TYPENAME range_value::type>& f) + operator|(const SinglePassRange& r, const replace_if_holder& f) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept)); @@ -145,10 +137,9 @@ namespace boost range_detail::forwarder2TU(); } - template + template< class Pred, class SinglePassRange, class Value > inline replaced_if_range - replace_if(SinglePassRange& rng, Pred pred, - BOOST_DEDUCED_TYPENAME range_value::type to) + replace_if(SinglePassRange& rng, Pred pred, Value to) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept)); @@ -157,12 +148,9 @@ namespace boost rng, pred, to); } - template + template< class Pred, class SinglePassRange, class Value > inline replaced_if_range - replace_if( - const SinglePassRange& rng, - Pred pred, - BOOST_DEDUCED_TYPENAME range_value::type to) + replace_if(const SinglePassRange& rng, Pred pred, Value to) { BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept)); From d99628981d1ff7181bee652bc5177342d79aaf4e Mon Sep 17 00:00:00 2001 From: Christopher Wecht Date: Fri, 1 Sep 2017 17:53:46 +0200 Subject: [PATCH 28/39] push_back: added support for not-copyable but moveable value-types like e.g. unique_ptr --- .../boost/range/algorithm_ext/push_back.hpp | 43 ++++++++++- test/algorithm_ext_test/push_back.cpp | 74 +++++++++++++++++++ 2 files changed, 116 insertions(+), 1 deletion(-) diff --git a/include/boost/range/algorithm_ext/push_back.hpp b/include/boost/range/algorithm_ext/push_back.hpp index 6fb9b9b..d741b62 100644 --- a/include/boost/range/algorithm_ext/push_back.hpp +++ b/include/boost/range/algorithm_ext/push_back.hpp @@ -20,9 +20,37 @@ namespace boost { - namespace range +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + namespace range_detail { +template < class Container, class Range > +inline Container& push_back_impl( Container& on, Range&& from, std::false_type) +{ + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_ASSERT_MSG(!range_detail::is_same_object(on, from), + "cannot move from a container to itself"); + on.insert( on.end(), + std::make_move_iterator(boost::begin(from)), + std::make_move_iterator(boost::end(from))); + return on; +} + +template < class Container, class Range > +inline Container& push_back_impl( Container& on, const Range& from, std::true_type) +{ + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + BOOST_ASSERT_MSG(!range_detail::is_same_object(on, from), + "cannot copy from a container to itself"); + on.insert( on.end(), boost::begin(from), boost::end(from)); + return on; +} + + } //namespace range_detail +#endif + + namespace range { +#if defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) template< class Container, class Range > inline Container& push_back( Container& on, const Range& from ) { @@ -34,6 +62,19 @@ inline Container& push_back( Container& on, const Range& from ) return on; } +#else + +template< class Container, class Range > +inline Container& push_back( Container& on, Range&& from ) +{ + BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); + range_detail::push_back_impl(on, + std::forward(from), + std::is_lvalue_reference() ); + return on; +} + +#endif } // namespace range using range::push_back; } // namespace boost diff --git a/test/algorithm_ext_test/push_back.cpp b/test/algorithm_ext_test/push_back.cpp index 7e9d539..b3e4754 100644 --- a/test/algorithm_ext_test/push_back.cpp +++ b/test/algorithm_ext_test/push_back.cpp @@ -19,6 +19,7 @@ #include #include + namespace { template< class Container > @@ -58,6 +59,76 @@ namespace test_push_back_impl< std::vector >(); test_push_back_impl< std::list >(); } + +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + // test type which is not copyable by moveable. + class noncopyable_int : boost::noncopyable { + private: + int i; + public: + noncopyable_int(int x) : i(x) {} + noncopyable_int(const noncopyable_int&) = delete; + noncopyable_int& operator=(const noncopyable_int&) = delete; + noncopyable_int(noncopyable_int&& o) : i(o.i) {} + noncopyable_int& operator=(noncopyable_int&& o) { return o; } + bool operator!=(const noncopyable_int &rhs) { return i != rhs.i; } + friend std::ostream &operator<<(std::ostream &os, const noncopyable_int& x); + }; + + std::ostream & operator<<(std::ostream &os, const noncopyable_int& x) + { + return os << x.i; + } + + template< class Container > + void test_push_back_move_impl(std::size_t n) + { + Container test; + Container reference; + for (std::size_t i = 0; i < n; ++i) + reference.push_back(noncopyable_int(i)); + + { + Container to_push_back; + for (std::size_t i = 0; i < n; ++i) + to_push_back.push_back(noncopyable_int(i)); + + boost::push_back(test, std::move(to_push_back)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } + // Do it again to push onto non-empty container + for (std::size_t i = 0; i < n; ++i) + reference.push_back(noncopyable_int(i)); + + { + Container to_push_back; + for (std::size_t i = 0; i < n; ++i) + to_push_back.push_back(noncopyable_int(i)); + + boost::push_back(test, std::move(to_push_back)); + + BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), + test.begin(), test.end() ); + } + } + + template< class Container > + void test_push_back_move_impl() + { + test_push_back_move_impl< Container >(0); + test_push_back_move_impl< Container >(1); + test_push_back_move_impl< Container >(2); + test_push_back_move_impl< Container >(100); + } + + void test_push_back_move() + { + test_push_back_move_impl< std::vector >(); + test_push_back_move_impl< std::list >(); + } +#endif } boost::unit_test::test_suite* @@ -67,6 +138,9 @@ init_unit_test_suite(int argc, char* argv[]) = BOOST_TEST_SUITE( "RangeTestSuite.algorithm_ext.push_back" ); test->add( BOOST_TEST_CASE( &test_push_back ) ); +#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) + test->add( BOOST_TEST_CASE( &test_push_back_move ) ); +#endif return test; } From 8b98b696ff7e1cbda27477294a0b17742266405e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 10 Sep 2017 03:01:13 +0300 Subject: [PATCH 29/39] Qualify boost::search in test/algorithm to avoid ambiguity with C++17's std::search --- test/algorithm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/algorithm.cpp b/test/algorithm.cpp index ebe0496..e945d42 100644 --- a/test/algorithm.cpp +++ b/test/algorithm.cpp @@ -457,7 +457,7 @@ void simple_compile_test() BOOST_RANGE_RETURNS_TEST2( find_end, v, std::less() ); BOOST_RANGE_RETURNS_TEST2( find_first_of, v, std::less() ); - BOOST_RANGE_RETURNS_TEST2( search, v, std::less() ); + BOOST_RANGE_RETURNS_TEST2( boost::search, v, std::less() ); BOOST_RANGE_RETURNS_TEST2( lower_bound, 0, std::less() ); BOOST_RANGE_RETURNS_TEST2( upper_bound, 0, std::less() ); From dfa3697764e38ed6fcb10adbf27e271b6b567bda Mon Sep 17 00:00:00 2001 From: Tony Lewis Date: Sat, 9 Sep 2017 21:46:28 +0100 Subject: [PATCH 30/39] Add missing const to adjacent_filtered_range --- include/boost/range/adaptor/adjacent_filtered.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/range/adaptor/adjacent_filtered.hpp b/include/boost/range/adaptor/adjacent_filtered.hpp index 287a4ae..405fe7b 100644 --- a/include/boost/range/adaptor/adjacent_filtered.hpp +++ b/include/boost/range/adaptor/adjacent_filtered.hpp @@ -181,7 +181,7 @@ namespace boost } template< class ForwardRng, class BinPredicate > - inline adjacent_filtered_range + inline adjacent_filtered_range operator|( const ForwardRng& r, const adjacent_excl_holder& f ) { From 4a729678fd47a069ba6a869fb978dbd48656b74a Mon Sep 17 00:00:00 2001 From: Jean-Philippe DUFRAIGNE Date: Sun, 24 Sep 2017 14:13:42 +0100 Subject: [PATCH 31/39] Fix transformed test compile error on GCC 5.4 The function object 'lambda' did not provide result_type like the other function objects did. The test now compile and pass using'b2' --- test/adaptor_test/transformed.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/adaptor_test/transformed.cpp b/test/adaptor_test/transformed.cpp index 9146f84..10f6a0c 100644 --- a/test/adaptor_test/transformed.cpp +++ b/test/adaptor_test/transformed.cpp @@ -44,6 +44,8 @@ namespace boost struct lambda { + typedef int result_type; + lambda(const lambda_init& init) {} lambda(const lambda& rhs) {} From 4614777aaf14b7561188a10e3e4aba6701d2757b Mon Sep 17 00:00:00 2001 From: neilgroves Date: Wed, 15 Nov 2017 23:21:32 +0000 Subject: [PATCH 32/39] Revert "Update irange.hpp" --- include/boost/range/irange.hpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/include/boost/range/irange.hpp b/include/boost/range/irange.hpp index a86a900..7d5fee5 100644 --- a/include/boost/range/irange.hpp +++ b/include/boost/range/irange.hpp @@ -203,22 +203,6 @@ namespace boost } }; - template - integer_range - irange(int last) - { - BOOST_ASSERT( 0 <= last ); - return integer_range(0, last); - } - - template - integer_range - irange(int first, int last) - { - BOOST_ASSERT( first <= last ); - return integer_range(first, last); - } - template integer_range irange(Integer first, Integer last) From e0d2e492a1e6b273fe7b5a9e85c675b2837636e8 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 2 Dec 2017 10:40:16 +0000 Subject: [PATCH 33/39] Include boost/next_prior.hpp where needed A recent change to boost/utility.hpp removed the include of this header, so now it's needed for boost::prior and boost::next. https://github.com/boostorg/utility/commit/b74f49f1e56e0be7eda4085de9aa0107526b423e --- include/boost/range/adaptor/sliced.hpp | 1 + include/boost/range/detail/microsoft.hpp | 1 + include/boost/range/detail/range_return.hpp | 1 + include/boost/range/iterator_range_core.hpp | 1 + 4 files changed, 4 insertions(+) diff --git a/include/boost/range/adaptor/sliced.hpp b/include/boost/range/adaptor/sliced.hpp index a09cbd0..f8d9612 100644 --- a/include/boost/range/adaptor/sliced.hpp +++ b/include/boost/range/adaptor/sliced.hpp @@ -15,6 +15,7 @@ #include #include #include +#include namespace boost { diff --git a/include/boost/range/detail/microsoft.hpp b/include/boost/range/detail/microsoft.hpp index 7b672c9..d04575c 100644 --- a/include/boost/range/detail/microsoft.hpp +++ b/include/boost/range/detail/microsoft.hpp @@ -58,6 +58,7 @@ #include #include #include // disable_if +#include #if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1) #include diff --git a/include/boost/range/detail/range_return.hpp b/include/boost/range/detail/range_return.hpp index 773a72a..9b98e09 100644 --- a/include/boost/range/detail/range_return.hpp +++ b/include/boost/range/detail/range_return.hpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace boost { diff --git a/include/boost/range/iterator_range_core.hpp b/include/boost/range/iterator_range_core.hpp index a9e9fc0..7f2dc3f 100644 --- a/include/boost/range/iterator_range_core.hpp +++ b/include/boost/range/iterator_range_core.hpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include From 1dac6a796e540a6c39fea4b420849eecabcaf5fa Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 2 Dec 2017 19:10:56 +0200 Subject: [PATCH 34/39] Add `quick` test target (for CI) --- test/Jamfile.v2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f038026..b195926 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -221,3 +221,5 @@ test-suite range : [ range-test value_type ] ; +# `quick` target (for CI) +alias quick : std_container ; From 937a411c3fb15a80f253e61ff4263f4752a87c2b Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 2 Dec 2017 19:17:02 +0200 Subject: [PATCH 35/39] Add .travis.yml --- .travis.yml | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ffa227a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,93 @@ +# Copyright 2016, 2017 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) + +language: cpp + +sudo: false + +python: "2.7" + +branches: + only: + - master + - develop + - /feature\/.*/ + +env: + matrix: + - BOGUS_JOB=true + +matrix: + + exclude: + - env: BOGUS_JOB=true + + include: + - os: linux + compiler: g++ + env: TOOLSET=gcc CXXSTD=03,11 + + - os: linux + compiler: g++-5 + env: TOOLSET=gcc-5 CXXSTD=03,11,14,1z + addons: + apt: + packages: + - g++-5 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-6 + env: TOOLSET=gcc-6 CXXSTD=03,11,14,1z + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-7 + env: TOOLSET=gcc-7 CXXSTD=03,11,14,17 + addons: + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: clang++ + env: TOOLSET=clang CXXSTD=03,11,14,1z + addons: + apt: + packages: + - libstdc++-4.9-dev + sources: + - ubuntu-toolchain-r-test + + - os: osx + compiler: clang++ + env: TOOLSET=clang CXXSTD=03,11,14,1z + +install: + - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true + - cd .. + - git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root + - cd boost-root + - git submodule update --init tools/build + - git submodule update --init libs/config + - git submodule update --init tools/boostdep + - cp -r $TRAVIS_BUILD_DIR/* libs/range + - python tools/boostdep/depinst/depinst.py range + - ./bootstrap.sh + - ./b2 headers + +script: + - ./b2 -j 3 libs/range/test toolset=$TOOLSET cxxstd=$CXXSTD + +notifications: + email: + on_success: always From 5408f220ddd6f32f8d7d64040cf4a94d2c975660 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 3 Dec 2017 03:16:30 +0200 Subject: [PATCH 36/39] Split Travis jobs to avoid timeout --- .travis.yml | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ffa227a..314afb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,17 @@ matrix: - os: linux compiler: g++-5 - env: TOOLSET=gcc-5 CXXSTD=03,11,14,1z + env: TOOLSET=gcc-5 CXXSTD=03,11 + addons: + apt: + packages: + - g++-5 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-5 + env: TOOLSET=gcc-5 CXXSTD=14,1z addons: apt: packages: @@ -40,7 +50,17 @@ matrix: - os: linux compiler: g++-6 - env: TOOLSET=gcc-6 CXXSTD=03,11,14,1z + env: TOOLSET=gcc-6 CXXSTD=03,11 + addons: + apt: + packages: + - g++-6 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-6 + env: TOOLSET=gcc-6 CXXSTD=14,1z addons: apt: packages: @@ -50,7 +70,17 @@ matrix: - os: linux compiler: g++-7 - env: TOOLSET=gcc-7 CXXSTD=03,11,14,17 + env: TOOLSET=gcc-7 CXXSTD=03,11 + addons: + apt: + packages: + - g++-7 + sources: + - ubuntu-toolchain-r-test + + - os: linux + compiler: g++-7 + env: TOOLSET=gcc-7 CXXSTD=14,17 addons: apt: packages: @@ -60,7 +90,11 @@ matrix: - os: linux compiler: clang++ - env: TOOLSET=clang CXXSTD=03,11,14,1z + env: TOOLSET=clang CXXSTD=03,11 + + - os: linux + compiler: clang++ + env: TOOLSET=clang CXXSTD=14,1z addons: apt: packages: @@ -70,7 +104,11 @@ matrix: - os: osx compiler: clang++ - env: TOOLSET=clang CXXSTD=03,11,14,1z + env: TOOLSET=clang CXXSTD=03,11 + + - os: osx + compiler: clang++ + env: TOOLSET=clang CXXSTD=14,1z install: - BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true From 5b2500872dc29017dd42cfe04ac8b7d2351f4b06 Mon Sep 17 00:00:00 2001 From: neilgroves Date: Wed, 3 Jan 2018 14:36:50 +0000 Subject: [PATCH 37/39] =?UTF-8?q?Revert=20"push=5Fback:=20added=20support?= =?UTF-8?q?=20for=20not-copyable=20but=20moveable=20value-types=20li?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boost/range/algorithm_ext/push_back.hpp | 43 +---------- test/algorithm_ext_test/push_back.cpp | 74 ------------------- 2 files changed, 1 insertion(+), 116 deletions(-) diff --git a/include/boost/range/algorithm_ext/push_back.hpp b/include/boost/range/algorithm_ext/push_back.hpp index d741b62..6fb9b9b 100644 --- a/include/boost/range/algorithm_ext/push_back.hpp +++ b/include/boost/range/algorithm_ext/push_back.hpp @@ -20,37 +20,9 @@ namespace boost { -#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) - namespace range_detail + namespace range { -template < class Container, class Range > -inline Container& push_back_impl( Container& on, Range&& from, std::false_type) -{ - BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_ASSERT_MSG(!range_detail::is_same_object(on, from), - "cannot move from a container to itself"); - on.insert( on.end(), - std::make_move_iterator(boost::begin(from)), - std::make_move_iterator(boost::end(from))); - return on; -} - -template < class Container, class Range > -inline Container& push_back_impl( Container& on, const Range& from, std::true_type) -{ - BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); - BOOST_ASSERT_MSG(!range_detail::is_same_object(on, from), - "cannot copy from a container to itself"); - on.insert( on.end(), boost::begin(from), boost::end(from)); - return on; -} - - } //namespace range_detail -#endif - - namespace range { -#if defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) template< class Container, class Range > inline Container& push_back( Container& on, const Range& from ) { @@ -62,19 +34,6 @@ inline Container& push_back( Container& on, const Range& from ) return on; } -#else - -template< class Container, class Range > -inline Container& push_back( Container& on, Range&& from ) -{ - BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); - range_detail::push_back_impl(on, - std::forward(from), - std::is_lvalue_reference() ); - return on; -} - -#endif } // namespace range using range::push_back; } // namespace boost diff --git a/test/algorithm_ext_test/push_back.cpp b/test/algorithm_ext_test/push_back.cpp index b3e4754..7e9d539 100644 --- a/test/algorithm_ext_test/push_back.cpp +++ b/test/algorithm_ext_test/push_back.cpp @@ -19,7 +19,6 @@ #include #include - namespace { template< class Container > @@ -59,76 +58,6 @@ namespace test_push_back_impl< std::vector >(); test_push_back_impl< std::list >(); } - -#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) - // test type which is not copyable by moveable. - class noncopyable_int : boost::noncopyable { - private: - int i; - public: - noncopyable_int(int x) : i(x) {} - noncopyable_int(const noncopyable_int&) = delete; - noncopyable_int& operator=(const noncopyable_int&) = delete; - noncopyable_int(noncopyable_int&& o) : i(o.i) {} - noncopyable_int& operator=(noncopyable_int&& o) { return o; } - bool operator!=(const noncopyable_int &rhs) { return i != rhs.i; } - friend std::ostream &operator<<(std::ostream &os, const noncopyable_int& x); - }; - - std::ostream & operator<<(std::ostream &os, const noncopyable_int& x) - { - return os << x.i; - } - - template< class Container > - void test_push_back_move_impl(std::size_t n) - { - Container test; - Container reference; - for (std::size_t i = 0; i < n; ++i) - reference.push_back(noncopyable_int(i)); - - { - Container to_push_back; - for (std::size_t i = 0; i < n; ++i) - to_push_back.push_back(noncopyable_int(i)); - - boost::push_back(test, std::move(to_push_back)); - - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } - // Do it again to push onto non-empty container - for (std::size_t i = 0; i < n; ++i) - reference.push_back(noncopyable_int(i)); - - { - Container to_push_back; - for (std::size_t i = 0; i < n; ++i) - to_push_back.push_back(noncopyable_int(i)); - - boost::push_back(test, std::move(to_push_back)); - - BOOST_CHECK_EQUAL_COLLECTIONS( reference.begin(), reference.end(), - test.begin(), test.end() ); - } - } - - template< class Container > - void test_push_back_move_impl() - { - test_push_back_move_impl< Container >(0); - test_push_back_move_impl< Container >(1); - test_push_back_move_impl< Container >(2); - test_push_back_move_impl< Container >(100); - } - - void test_push_back_move() - { - test_push_back_move_impl< std::vector >(); - test_push_back_move_impl< std::list >(); - } -#endif } boost::unit_test::test_suite* @@ -138,9 +67,6 @@ init_unit_test_suite(int argc, char* argv[]) = BOOST_TEST_SUITE( "RangeTestSuite.algorithm_ext.push_back" ); test->add( BOOST_TEST_CASE( &test_push_back ) ); -#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) - test->add( BOOST_TEST_CASE( &test_push_back_move ) ); -#endif return test; } From 795046f8fc30e359d0a4826cd5bb652d3ccf3855 Mon Sep 17 00:00:00 2001 From: Nathan Cook Date: Wed, 28 Feb 2018 10:55:24 +0000 Subject: [PATCH 38/39] Fix Error C4596: 'difference_type': illegal qualified name in member declaration when compiling with VS 2017 Professional 15.5.6 --- include/boost/range/concepts.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/range/concepts.hpp b/include/boost/range/concepts.hpp index 87c1e98..6fac727 100644 --- a/include/boost/range/concepts.hpp +++ b/include/boost/range/concepts.hpp @@ -252,7 +252,7 @@ namespace boost { n = i - j; } private: - BOOST_DEDUCED_TYPENAME RandomAccessIteratorConcept::difference_type n; + BOOST_DEDUCED_TYPENAME difference_type n; Iterator i; Iterator j; #endif From f1906e914eaaf76408a0a4e69c61c457c08abba8 Mon Sep 17 00:00:00 2001 From: Nathan Cook Date: Wed, 28 Feb 2018 13:43:34 +0000 Subject: [PATCH 39/39] use _MSC_VER to guard fix for C4596 when compiling with MSVC141 --- include/boost/range/concepts.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/boost/range/concepts.hpp b/include/boost/range/concepts.hpp index 6fac727..6fef2ea 100644 --- a/include/boost/range/concepts.hpp +++ b/include/boost/range/concepts.hpp @@ -252,7 +252,12 @@ namespace boost { n = i - j; } private: + // MSVC 14.1 - avoid C4596: 'difference_type': illegal qualified name in member declaration + #if defined(_MSC_VER) && _MSC_VER >= 1912 BOOST_DEDUCED_TYPENAME difference_type n; + #else + BOOST_DEDUCED_TYPENAME RandomAccessIteratorConcept::difference_type n; + #endif Iterator i; Iterator j; #endif