Compare commits

...

101 Commits

Author SHA1 Message Date
4614777aaf Revert "Update irange.hpp" 2017-11-15 23:21:32 +00:00
83a352fa58 Merge pull request #45 from mateuszlewko/develop
Update irange.hpp
2017-11-15 19:52:41 +00:00
0e0d77cfab Merge pull request #56 from tonyelewis/add_const_to_adj_filt_rng
Add missing const to adjacent_filtered_range
2017-11-15 19:51:18 +00:00
d1f36fba8d Merge pull request #54 from cwecht/push_back_move_support
push_back: added support for not-copyable but moveable value-types li…
2017-11-15 19:51:00 +00:00
4283443532 Merge pull request #57 from jeanphilippeD/fix_transformed_test
Fix transformed test compile error on GCC 5.4
2017-11-15 19:49:05 +00:00
3771624560 Merge pull request #43 from timblechmann/topic/unary-irange
irange: introduce one-parameter variant of irange
2017-11-15 19:48:19 +00:00
4a729678fd 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'
2017-09-24 14:13:42 +01:00
dfa3697764 Add missing const to adjacent_filtered_range 2017-09-14 20:07:07 +01:00
8b98b696ff Qualify boost::search in test/algorithm to avoid ambiguity with C++17's std::search 2017-09-10 03:01:13 +03:00
d99628981d push_back: added support for not-copyable but moveable value-types like e.g. unique_ptr 2017-09-01 17:53:46 +02:00
e65434eb4f Merge pull request #53 from morinmorin/fix_c++03_breakage
Fix breakage in replaced adaptor for C++03
2017-07-12 14:18:05 +01:00
93513a3801 Make rng | replaced_if consistent with rng | replaced 2017-07-12 22:08:22 +09:00
93eb91e63e Fix breakage in replaced adaptor for C++03 2017-07-12 22:06:58 +09:00
f3a4246bd9 Merge pull request #48 from t-wynants/fix-ticket-12754-sfinae-friendly-overload
Ticket 12754 - sfinea friendly boost::range_details::replace_holder overloads
2017-06-30 12:45:34 +01:00
796080bbb8 Merge pull request #46 from jeanphilippeD/lambda_copy_transform_it
Allow iterator copy for lambda in transformed and filtered
2017-06-30 12:43:38 +01:00
370f1a4cd2 Merge pull request #51 from DanielaE/feature/replace-removed-c++98-stuff
Conditionally replace deprecated/removed C++98 function adapters and …
2017-06-30 12:42:59 +01:00
7d564572e2 Merge pull request #50 from orgads/patch-1
Fix broken link in overview
2017-06-30 12:42:41 +01:00
9afc3bcbe2 Merge pull request #52 from morinmorin/use_boost_distance_from_iterator_lib
Make boost::distance traversal-category-aware (and constexpr in C++14)
2017-06-30 12:40:18 +01:00
69409ed63a Make boost::distance traversal-category-aware (and constexpr in C++14) 2017-06-30 20:02:53 +09:00
23e5801e2a Conditionally replace deprecated/removed C++98 function adapters and std::random_shuffle by equivalents.
Signed-off-by: Daniela Engert <dani@ngrt.de>
2017-05-05 14:15:11 +02:00
e476e1900a Fix broken link in overview 2017-05-03 10:18:25 +03:00
452b1bb7e7 Merge pull request #44 from apolukhin/develop
Added BOOST_CONSTEXPR for begin()/end()
2017-04-17 14:39:19 +01:00
7b89c747d6 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
2017-01-12 17:45:31 +01:00
deb3ae9800 Merge branch 'master' into develop 2016-11-26 22:45:08 -08:00
56d470635d Qualify call to boost::size to avoid ambiguity with std::size 2016-11-26 22:44:31 -08:00
5c70a54597 Merge branch 'master' into develop 2016-11-23 14:56:09 -08:00
f829c55c72 Merge pull request #47 from boostorg/fix-boost-size_type
Don't assume that because type `T` is a range that `const T` is also a range.
2016-11-23 14:54:26 -08:00
910fc7bf82 Qualify call to boost::size to avoid ambiguity with std::size 2016-11-23 14:47:42 -08:00
67c18ac1f1 Merge remote-tracking branch 'origin/master' into develop 2016-11-18 21:28:24 -08:00
5787c56994 Merge pull request #47 from boostorg/fix-boost-size_type
Don't assume that because type `T` is a range that `const T` is also a range.
2016-11-18 12:06:32 -08:00
9e5680b590 Don't assume that because type T is a range that const T is also a range.
size_type<const T> erroneously dispatches to detail::size_type_<T>. 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.
2016-11-18 11:50:32 -08:00
1b4f8100ef 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<T> using function
emplace():')
2016-10-23 23:27:31 +01:00
7567dce0c1 Add, and update, documentation build targets. 2016-10-10 11:39:52 -05:00
e48b9c38e7 Add, and update, documentation build targets. 2016-10-07 23:07:36 -05:00
283b8beddc Update irange.hpp
Added: irange(int last), irange(int first, int last)
2016-04-09 19:32:22 +02:00
4ce15f9b52 Added BOOST_CONSTEXPR for begin()/end() 2016-01-24 22:51:19 +03:00
bb43887430 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).
2016-01-17 11:40:55 +01:00
5a37aa4e98 Merge pull request #41 from robin-eckert/adaptor_ref_unwrapped
add a new range adaptor boost::adaptors::ref_unwrapped
2016-01-04 16:38:36 +00:00
0e931f4a80 Merge pull request #33 from tobias-loew/master
Ticket #10397 - compilation error with mfc-iteratior-support: ambiguous symbol
2016-01-04 16:37:18 +00:00
5196baa1b0 Merge pull request #42 from rydotyosh/patch-1
[range] fixed minor typo in docs
2016-01-04 16:36:58 +00:00
1947daf1b5 Merge pull request #39 from MarcelRaad/fix_iterator_pair_test
Fix test compilation
2016-01-04 16:36:42 +00:00
7ca999c662 [range] fixed minor typo in docs 2015-11-14 15:41:48 +09:00
e7ebe14707 Merge pull request #40 from treh/treh-patch-1
qualify boost::range_[const|mutable]_iterator
2015-11-05 11:42:43 +00:00
3225aaf82b 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.
2015-11-04 19:12:26 +01:00
262c0f96b3 qualify boost::range_[const|mutable]_iterator
otherwise boost::range_detail::range_[const|mutable]_iterator gets accidentily called
2015-11-04 09:58:15 +01:00
1a3aeeb336 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.
2015-09-22 00:51:41 +02:00
78a8f5bf3d Merge pull request #38 from MarcelRaad/patch-1
Fix compilation
2015-09-18 09:08:01 +01:00
9bf860fd30 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.
2015-09-18 09:54:08 +02:00
64c83341ab Merge pull request #37 from mclow/develop
Remove use of deprecated macros
2015-09-13 21:52:09 +01:00
6241dc62aa Remove use of deprecated macros 2015-09-11 15:16:24 -07:00
f83381d938 Merge pull request #36 from morinmorin/fix/ticket11563
Fix ticket 11563 (boost::range behavior changed from 1.55 to 1.56)
2015-09-07 07:45:08 +01:00
926318105e Merge pull request #35 from morinmorin/fix/credit_in_trac5014
Fix credit in ticket 5014 testcase
2015-09-07 07:44:51 +01:00
140866b402 Merge pull request #34 from morinmorin/fix/ticket11528
Fix ticket 11528 (MSVS 2015 + boost::range: STL and Boost iterators)
2015-09-07 07:44:35 +01:00
490ba3fdcd Reapply r85400 (this time use Iterator1 instead of Iterator2 as per r85691) and enhance the testcase; fixes ticket 11563. 2015-08-21 21:40:25 +09:00
e4f456d438 Fix credit in ticket 5014 testcase 2015-08-20 20:36:19 +09:00
adcb071dc6 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. 2015-08-20 20:03:08 +09:00
4f66482414 Ticket #10397 - compilation error with mfc-iteratior-support: ambiguous symbol
fixed compilation error for mfc-iteration-support

changed
boost::range_detail::range_const_iterator
to
boost::range_detail::range_const_iterator_helper

to address compilation error when using mfc-iteration-support
2015-08-12 15:32:31 +02:00
7fad9837fb Merge pull request #32 from mclow/develop
Add char16_t and char32_t to the list of literal string types. Fixes …
2015-05-13 12:23:39 +01:00
11dbb1cb5a Add char16_t and char32_t to the list of literal string types. Fixes bug 11265 in Boost.StringAlgo's join. 2015-05-12 21:26:05 -06:00
e961e66909 Merge pull request #26 from Yasami/develop
fix missing return statement
2015-04-27 19:51:18 +01:00
8847fd63cb Merge pull request #30 from nekko1119/pr-fix-doc
Fix parameters in replaced adaptor document
2015-04-27 19:50:57 +01:00
62941f740d Merge pull request #31 from eldiener/develop
Use operator || rather than boost::mpl::or_ for constant boolean exprtession.
2015-04-27 19:49:28 +01:00
0c930a3697 Fix syntax error. 2015-04-27 14:06:59 -04:00
09084d6355 Use || operator instead of boost::mpl::or_ for constant boolean value since current Boost compilers all support operator use. 2015-04-27 13:18:48 -04:00
9ca1622dd0 Fix parameters in replaced adaptor document 2015-04-22 02:48:05 +09:00
7669f52547 Merge branch 'develop' 2015-04-21 08:22:15 +01:00
c6c4a8f3c1 Merge pull request #29 from ericniebler/develop
fix build break on msvc-8.0
2015-04-19 13:28:52 -07:00
3d5f3611ba fix build break on msvc-8.0 2015-04-18 11:42:38 -07:00
8c1180f7f2 Merge pull request #27 from eldiener/develop
Remove dependency on type traits ice_xxx.hpp headers, which are deprecat...
2015-04-14 09:27:05 +01:00
8ea11f9281 Merge pull request #28 from ericniebler/develop
make range_iterator, range_difference, and range_size SFINAE-friendly, r...
2015-04-14 09:26:35 +01:00
811b27141a make range_iterator, range_difference, and range_size SFINAE-friendly, refs #11187 2015-04-14 00:57:54 -07:00
a53bd134b2 Remove dependency on type traits ice_xxx.hpp headers, which are deprecated. 2015-04-02 01:54:45 -04:00
0b28fd043f Fix for MSVC subrange iterator conversions. 2015-02-09 01:21:16 +00:00
474c62ab16 fix missing return statement 2015-02-04 15:52:15 +09:00
de206a64db ticket10514 subrange unit test added. 2015-02-02 20:26:31 +00:00
435ca994bf Ticket 10989 - strided adapter category. 2015-02-02 20:17:04 +00:00
4a80ccd50d Ticket 10988 - Filtered adaptor should only require SinglePassRange. 2015-02-01 19:05:58 +00:00
6f11252633 Ticket 10336 - unit test added. 2015-01-31 14:50:58 +00:00
2356783e17 Merge branch 'develop'
Conflicts:
	include/boost/range/detail/any_iterator.hpp
	test/iterator_range.cpp
2015-01-31 13:38:08 +00:00
688d1bc418 Update inclusion of polymorphic_cast.hpp to cat.hpp 2015-01-31 13:31:33 +00:00
dcbe4f9365 Merge pull request #21 from Lastique/patch-1
Use public interface of Boost.Iterator
2015-01-25 19:15:31 +00:00
9b3a21b5e3 Merge pull request #25 from levinmk/master
fix ticket #10754
2015-01-25 19:15:05 +00:00
e362bb1855 Merge pull request #20 from danieljames/metadata
Create metadata file.
2015-01-25 20:30:52 +02:00
1965b797d8 fix ticket #10754
as described in https://svn.boost.org/trac/boost/ticket/10754, postfix_increment_proxy and writable_postfix_increment_proxy were moved to boost::iterators::detail namespace
2014-12-12 16:43:32 -06:00
4f3bdbe4d3 Merge pull request #24 from steveire/remove-algorithm-dep
Remove algorithm dep
2014-09-25 01:12:32 +01:00
8bb3a85f68 Use local sfinae typedefs for yes_type and no_type.
Remove dependency on Boost.Algorithm library.
2014-09-10 15:37:48 +02:00
0e9a9e613b Rely on the 'typename' keyword from the compiler.
Remove trailing whitespace from modified lines.

 git grep -l BOOST_STRING_TYPENAME | xargs sed -i 's|BOOST_STRING_TYPENAME *$|typename|'
 git grep -l BOOST_STRING_TYPENAME | xargs sed -i 's|BOOST_STRING_TYPENAME \(.*\) +$|typename \1|'
 git grep -l BOOST_STRING_TYPENAME | xargs sed -i 's|BOOST_STRING_TYPENAME|typename|'

Remove include of header from Boost.Algorithm library providing the define.
2014-09-10 15:37:45 +02:00
18e5bfd037 Merge pull request #22 from insideoutclub/develop
Update algorithms.qbk
2014-09-05 13:47:21 -04:00
51b8115fc1 Update algorithms.qbk
Fixed the spelling of "old-fashioned".
2014-09-05 10:34:21 -07:00
4617c43b5e Use public interface of Boost.Iterator 2014-08-30 16:04:46 +04:00
a58e59ec67 Add metadata file. 2014-08-18 15:09:55 +01:00
470a28ecb6 replace =default in test to fix iterator_range.cpp unit test regression with older compilers. 2014-08-15 12:26:30 +01:00
1e509e6749 Merge pull request #19 from ericniebler/develop
Possible fix for iterator_range SFINAE bug
2014-08-10 17:07:10 +01:00
7d13f63d5d avoid SFINAE problem in iterator_range constructor 2014-08-09 14:48:57 -07:00
d6bce30c4f Merge remote-tracking branch 'origin/develop' into develop 2014-08-09 12:30:26 -07:00
dc0a6b6340 Add upgrade documentation about pop_front() and pop_back() being renamed. 2014-08-04 19:32:37 +01:00
7fb879a283 Hotfix to add back advance_begin and advance_end. 2014-08-04 17:53:14 +01:00
4716c1efec Merge pull request #16 from ericniebler/develop
attempted fix for iterator_range relational operators bug
2014-07-30 07:53:31 -07:00
9d8034d541 Merge remote-tracking branch 'origin/develop' into develop 2014-07-29 19:35:26 -07:00
48dfb68045 Merge pull request #17 from ericniebler/iterators-namespace
accomodate new boost::iterators namespace.
2014-07-29 18:21:34 -07:00
1617a513d2 accomodate new boost::iterators namespace. See boostorg/iterator@dc96d371fa 2014-07-29 18:18:02 -07:00
65 changed files with 1082 additions and 439 deletions

View File

@ -28,3 +28,8 @@ boostbook quickbook
<format>pdf:<xsl:param>img.src.path=$(images_location)/
;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : quickbook ;
explicit boostrelease ;

View File

@ -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

View File

@ -46,7 +46,7 @@
[[`<boost/range/adaptor/copied.hpp>`] [__range_adaptors_copied__]]
[[`<boost/range/adaptor/filtered.hpp>`] [__range_adaptors_filtered__]]
[[`<boost/range/adaptor/indexed.hpp>`] [__range_adaptors_indexed__]]
[[`<boost/range/adaptor/indirected.hpp.`] [__range_adaptors_indirected__]]
[[`<boost/range/adaptor/indirected.hpp>`] [__range_adaptors_indirected__]]
[[`<boost/range/adaptor/map.hpp>`] [__range_adaptors_map_keys__ __range_adaptors_map_values__]]
[[`<boost/range/adaptor/replaced.hpp>`] [__range_adaptors_replaced__]]
[[`<boost/range/adaptor/replaced_if.hpp>`] [__range_adaptors_replaced_if__]]

View File

@ -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]

View File

@ -12,9 +12,9 @@
]
* [*Precondition:] The `value_type` of the range is convertible to the argument type of `pred`.
* [*Postcondition:] For all adjacent elements `[x]` in the returned range, `pred(x)` is `true`.
* [*Postcondition:] For all elements `[x]` in the returned range, `pred(x)` is `true`.
* [*Throws:] Whatever the copy constructor of `pred` might throw.
* [*Range Category:] __forward_range__
* [*Range Category:] __singlepass_range__
* [*Range Return Type:] `boost::filtered_range<decltype(rng)>`
* [*Returned Range Category:] The minimum of the range category of `rng` and __bidirectional_range__

View File

@ -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<decltype(rng)>`
* [*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]

View File

@ -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:]

View File

@ -63,7 +63,7 @@ std::vector<int> vec = ...;
boost::erase(vec, boost::unique<boost::return_found_end>(boost::sort(vec)));
``
Notice the use of `boost::return_found_end`. What if we wanted to erase all the duplicates except one of them? In old-fashined STL-programming we might write
Notice the use of `boost::return_found_end`. What if we wanted to erase all the duplicates except one of them? In old-fashioned STL-programming we might write
``
// assume 'vec' is already sorted

View File

@ -10,7 +10,11 @@
``
template<class Integer>
iterator_range< range_detail::integer_iterator<Integer> >
irange(Integer first, Integer last);
irange(Integer last);
template<class Integer>
iterator_range< range_detail::integer_iterator<Integer> >
irange(Integer first, Integer last);
template<class Integer, class StepSize>
iterator_range< range_detail::integer_iterator_with_step<Integer, StepSize> >
@ -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]

View File

@ -181,7 +181,7 @@ namespace boost
}
template< class ForwardRng, class BinPredicate >
inline adjacent_filtered_range<BinPredicate, ForwardRng, false>
inline adjacent_filtered_range<BinPredicate, const ForwardRng, false>
operator|( const ForwardRng& r,
const adjacent_excl_holder<BinPredicate>& f )
{

View File

@ -56,23 +56,23 @@ namespace boost
{ }
};
template< class ForwardRange, class Predicate >
inline filtered_range<Predicate, ForwardRange>
operator|(ForwardRange& r,
template< class SinglePassRange, class Predicate >
inline filtered_range<Predicate, SinglePassRange>
operator|(SinglePassRange& r,
const filter_holder<Predicate>& f)
{
BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return filtered_range<Predicate, ForwardRange>( f.val, r );
BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange>));
return filtered_range<Predicate, SinglePassRange>( f.val, r );
}
template< class ForwardRange, class Predicate >
inline filtered_range<Predicate, const ForwardRange>
operator|(const ForwardRange& r,
template< class SinglePassRange, class Predicate >
inline filtered_range<Predicate, const SinglePassRange>
operator|(const SinglePassRange& r,
const filter_holder<Predicate>& f )
{
BOOST_RANGE_CONCEPT_ASSERT((
ForwardRangeConcept<const ForwardRange>));
return filtered_range<Predicate, const ForwardRange>( f.val, r );
SinglePassRangeConcept<const SinglePassRange>));
return filtered_range<Predicate, const SinglePassRange>( f.val, r );
}
} // 'range_detail'
@ -93,23 +93,26 @@ namespace boost
range_detail::forwarder<range_detail::filter_holder>();
}
template<class ForwardRange, class Predicate>
inline filtered_range<Predicate, ForwardRange>
filter(ForwardRange& rng, Predicate filter_pred)
{
BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return range_detail::filtered_range<Predicate, ForwardRange>( filter_pred, rng );
}
template<class ForwardRange, class Predicate>
inline filtered_range<Predicate, const ForwardRange>
filter(const ForwardRange& rng, Predicate filter_pred)
template<class SinglePassRange, class Predicate>
inline filtered_range<Predicate, SinglePassRange>
filter(SinglePassRange& rng, Predicate filter_pred)
{
BOOST_RANGE_CONCEPT_ASSERT((
ForwardRangeConcept<const ForwardRange>));
SinglePassRangeConcept<SinglePassRange>));
return range_detail::filtered_range<Predicate, const ForwardRange>( filter_pred, rng );
return range_detail::filtered_range<
Predicate, SinglePassRange>( filter_pred, rng );
}
template<class SinglePassRange, class Predicate>
inline filtered_range<Predicate, const SinglePassRange>
filter(const SinglePassRange& rng, Predicate filter_pred)
{
BOOST_RANGE_CONCEPT_ASSERT((
SinglePassRangeConcept<const SinglePassRange>));
return range_detail::filtered_range<
Predicate, const SinglePassRange>( filter_pred, rng );
}
} // 'adaptors'

View File

@ -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 <boost/range/adaptor/transformed.hpp>
#include <boost/range/reference.hpp>
#include <boost/range/concepts.hpp>
#include <utility>
#if !defined(BOOST_NO_CXX11_DECLTYPE)
namespace boost
{
namespace range_detail
{
struct ref_unwrapped_forwarder {};
template<class SinglePassRange>
struct unwrap_ref
{
typedef BOOST_DEDUCED_TYPENAME
range_reference<SinglePassRange>::type argument_type;
using result_type = decltype(std::declval<argument_type>().get() );
result_type operator()( argument_type &&r ) const
{
return r.get();
}
};
template<class SinglePassRange>
class unwrap_ref_range
: public transformed_range<unwrap_ref<SinglePassRange>,
SinglePassRange>
{
using base = transformed_range<unwrap_ref<SinglePassRange>,
SinglePassRange>;
public:
using transform_fn_type = unwrap_ref<SinglePassRange>;
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<class SinglePassRange>
inline unwrap_ref_range<SinglePassRange>
operator|(SinglePassRange& r, ref_unwrapped_forwarder)
{
BOOST_RANGE_CONCEPT_ASSERT((
SinglePassRangeConcept<SinglePassRange>));
return operator|( r,
boost::adaptors::transformed(unwrap_ref<SinglePassRange>()));
}
}
using range_detail::unwrap_ref_range;
namespace adaptors
{
namespace
{
const range_detail::ref_unwrapped_forwarder ref_unwrapped =
range_detail::ref_unwrapped_forwarder();
}
template<class SinglePassRange>
inline unwrap_ref_range<SinglePassRange>
ref_unwrap(SinglePassRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT((
SinglePassRangeConcept<SinglePassRange>));
return unwrap_ref_range<SinglePassRange>(
range_detail::unwrap_ref<SinglePassRange>(), rng );
}
} // 'adaptors'
}
#endif
#endif

View File

@ -101,12 +101,9 @@ namespace boost
void operator=(const replace_holder&);
};
template< class SinglePassRange >
template< class SinglePassRange, class Value >
inline replaced_range<SinglePassRange>
operator|(
SinglePassRange& r,
const replace_holder<
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange>::type>& f )
operator|(SinglePassRange& r, const replace_holder<Value>& f)
{
BOOST_RANGE_CONCEPT_ASSERT((
SinglePassRangeConcept<SinglePassRange>));
@ -114,12 +111,9 @@ namespace boost
return replaced_range<SinglePassRange>(r, f.val1, f.val2);
}
template< class SinglePassRange >
template< class SinglePassRange, class Value >
inline replaced_range<const SinglePassRange>
operator|(
const SinglePassRange& r,
const replace_holder<
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange>::type>& f)
operator|(const SinglePassRange& r, const replace_holder<Value>& f)
{
BOOST_RANGE_CONCEPT_ASSERT((
SinglePassRangeConcept<const SinglePassRange>));
@ -139,11 +133,9 @@ namespace boost
range_detail::forwarder2<range_detail::replace_holder>();
}
template<class SinglePassRange>
template< class SinglePassRange, class Value >
inline replaced_range<SinglePassRange>
replace(SinglePassRange& rng,
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange>::type from,
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange>::type to)
replace(SinglePassRange& rng, Value from, Value to)
{
BOOST_RANGE_CONCEPT_ASSERT((
SinglePassRangeConcept<SinglePassRange>));
@ -151,11 +143,9 @@ namespace boost
return replaced_range<SinglePassRange>(rng, from, to);
}
template<class SinglePassRange>
template< class SinglePassRange, class Value >
inline replaced_range<const SinglePassRange>
replace(const SinglePassRange& rng,
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange>::type from,
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange>::type to)
replace(const SinglePassRange& rng, Value from, Value to)
{
BOOST_RANGE_CONCEPT_ASSERT((
SinglePassRangeConcept<const SinglePassRange>));

View File

@ -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<Pred, SinglePassRange>
operator|(
SinglePassRange& r,
const replace_if_holder<
Pred,
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange>::type>& f)
operator|(SinglePassRange& r, const replace_if_holder<Pred, Value>& f)
{
BOOST_RANGE_CONCEPT_ASSERT((
SinglePassRangeConcept<SinglePassRange>));
@ -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<Pred, const SinglePassRange>
operator|(
const SinglePassRange& r,
const replace_if_holder<
Pred,
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange>::type>& f)
operator|(const SinglePassRange& r, const replace_if_holder<Pred, Value>& f)
{
BOOST_RANGE_CONCEPT_ASSERT((
SinglePassRangeConcept<const SinglePassRange>));
@ -145,10 +137,9 @@ namespace boost
range_detail::forwarder2TU<range_detail::replace_if_holder>();
}
template<class Pred, class SinglePassRange>
template< class Pred, class SinglePassRange, class Value >
inline replaced_if_range<Pred, SinglePassRange>
replace_if(SinglePassRange& rng, Pred pred,
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange>::type to)
replace_if(SinglePassRange& rng, Pred pred, Value to)
{
BOOST_RANGE_CONCEPT_ASSERT((
SinglePassRangeConcept<SinglePassRange>));
@ -157,12 +148,9 @@ namespace boost
rng, pred, to);
}
template<class Pred, class SinglePassRange>
template< class Pred, class SinglePassRange, class Value >
inline replaced_if_range<Pred, const SinglePassRange>
replace_if(
const SinglePassRange& rng,
Pred pred,
BOOST_DEDUCED_TYPENAME range_value<const SinglePassRange>::type to)
replace_if(const SinglePassRange& rng, Pred pred, Value to)
{
BOOST_RANGE_CONCEPT_ASSERT((
SinglePassRangeConcept<const SinglePassRange>));

View File

@ -603,7 +603,7 @@ namespace boost
template<
class Rng,
class Category =
typename iterator_traversal<
typename iterators::pure_iterator_traversal<
typename range_iterator<Rng>::type
>::type
>

View File

@ -9,12 +9,12 @@
#ifndef BOOST_RANGE_ALGORITHM_MAX_ELEMENT_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_MAX_ELEMENT_HPP_INCLUDED
#include <boost/algorithm/minmax_element.hpp>
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
@ -32,7 +32,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
max_element(ForwardRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
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<const ForwardRange>::type
max_element(const ForwardRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
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<ForwardRange>::type
max_element(ForwardRange& rng, BinaryPredicate pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
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<const ForwardRange>::type
max_element(const ForwardRange& rng, BinaryPredicate pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
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<ForwardRange> ));
return range_return<ForwardRange,re>::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<const ForwardRange> ));
return range_return<const ForwardRange,re>::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<ForwardRange> ));
return range_return<ForwardRange,re>::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<const ForwardRange> ));
return range_return<const ForwardRange,re>::pack(
std::max_element(boost::begin(rng), boost::end(rng), pred),
boost::first_max_element(boost::begin(rng), boost::end(rng), pred),
rng);
}

View File

@ -9,12 +9,12 @@
#ifndef BOOST_RANGE_ALGORITHM_MIN_ELEMENT_HPP_INCLUDED
#define BOOST_RANGE_ALGORITHM_MIN_ELEMENT_HPP_INCLUDED
#include <boost/algorithm/minmax_element.hpp>
#include <boost/concept_check.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <algorithm>
namespace boost
{
@ -32,7 +32,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
min_element(ForwardRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
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<const ForwardRange>::type
min_element(const ForwardRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
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<ForwardRange>::type
min_element(ForwardRange& rng, BinaryPredicate pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<ForwardRange> ));
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<const ForwardRange>::type
min_element(const ForwardRange& rng, BinaryPredicate pred)
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<const ForwardRange> ));
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<ForwardRange> ));
return range_return<ForwardRange,re>::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<const ForwardRange> ));
return range_return<const ForwardRange,re>::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<ForwardRange> ));
return range_return<ForwardRange,re>::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<const ForwardRange> ));
return range_return<const ForwardRange,re>::pack(
std::min_element(boost::begin(rng), boost::end(rng), pred),
boost::first_min_element(boost::begin(rng), boost::end(rng), pred),
rng);
}

View File

@ -14,12 +14,85 @@
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <algorithm>
#ifdef BOOST_NO_CXX98_RANDOM_SHUFFLE
#include <cstdlib>
#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<result_type>(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<class RandomAccessRange>
inline RandomAccessRange& random_shuffle(RandomAccessRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
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<class RandomAccessRange>
inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
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<class RandomAccessRange, class Generator>
inline RandomAccessRange& random_shuffle(RandomAccessRange& rng, Generator& gen)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<RandomAccessRange> ));
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<class RandomAccessRange, class Generator>
inline const RandomAccessRange& random_shuffle(const RandomAccessRange& rng, Generator& gen)
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessRangeConcept<const RandomAccessRange> ));
std::random_shuffle(boost::begin(rng), boost::end(rng), gen);
detail::random_shuffle(boost::begin(rng), boost::end(rng), gen);
return rng;
}

View File

@ -39,6 +39,7 @@ inline Container& insert( Container& on, const Range& from )
BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Range> ));
on.insert(boost::begin(from), boost::end(from));
return on;
}
} // namespace range

View File

@ -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<Range> ));
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<const Range> ));
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<Container> ));
range_detail::push_back_impl(on,
std::forward<Range>(from),
std::is_lvalue_reference<Range>() );
return on;
}
#endif
} // namespace range
using range::push_back;
} // namespace boost

View File

@ -25,6 +25,11 @@
#include <boost/detail/workaround.hpp>
#include <cstring>
#if !defined(BOOST_NO_CXX11_CHAR16_T) || !defined(BOOST_NO_CXX11_CHAR32_T)
#include <string> // for std::char_traits
#endif
#ifndef BOOST_NO_CWCHAR
#include <cwchar>
#endif
@ -38,6 +43,20 @@ namespace boost
return strlen( s );
}
#ifndef BOOST_NO_CXX11_CHAR16_T
inline std::size_t length( const char16_t* s )
{
return std::char_traits<char16_t>::length( s );
}
#endif
#ifndef BOOST_NO_CXX11_CHAR32_T
inline std::size_t length( const char32_t* s )
{
return std::char_traits<char32_t>::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_CXX11_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_CXX11_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* )
{

View File

@ -36,7 +36,7 @@ namespace range_detail
//////////////////////////////////////////////////////////////////////
template< typename C >
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
range_begin( C& c )
{
//
@ -52,13 +52,13 @@ namespace range_detail
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline Iterator range_begin( const std::pair<Iterator,Iterator>& p )
BOOST_CONSTEXPR inline Iterator range_begin( const std::pair<Iterator,Iterator>& p )
{
return p.first;
}
template< typename Iterator >
inline Iterator range_begin( std::pair<Iterator,Iterator>& p )
BOOST_CONSTEXPR inline Iterator range_begin( std::pair<Iterator,Iterator>& 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<T>::type begin( T& r )
BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator<T>::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<T>::type begin( T& r )
}
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
{
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
using namespace range_detail;

View File

@ -25,6 +25,8 @@
#include <boost/range/detail/misc_concept.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <iterator>
/*!
* \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<Iterator>::reference r1(*i);
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::reference r1(*i);
boost::ignore_unused_variable_warning(r1);
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r2(*(++i));
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::reference r2(*(++i));
boost::ignore_unused_variable_warning(r2);
}
private:
@ -181,7 +183,7 @@ namespace boost {
, DefaultConstructible<Iterator>
{
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
typedef BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::difference_type difference_type;
typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::difference_type difference_type;
BOOST_MPL_ASSERT((is_integral<difference_type>));
BOOST_MPL_ASSERT_RELATION(std::numeric_limits<difference_type>::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<Iterator>::reference r(*(i++));
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::reference r(*(i++));
boost::ignore_unused_variable_warning(r);
}
private:

View File

@ -36,7 +36,7 @@ namespace boost
BOOST_RANGE_EXTRACT_OPTIONAL_TYPE( const_iterator )
template< typename C >
struct range_const_iterator
struct range_const_iterator_helper
: extract_const_iterator<C>
{};
@ -45,7 +45,7 @@ struct range_const_iterator
//////////////////////////////////////////////////////////////////////////
template< typename Iterator >
struct range_const_iterator<std::pair<Iterator,Iterator> >
struct range_const_iterator_helper<std::pair<Iterator,Iterator> >
{
typedef Iterator type;
};
@ -55,7 +55,7 @@ struct range_const_iterator<std::pair<Iterator,Iterator> >
//////////////////////////////////////////////////////////////////////////
template< typename T, std::size_t sz >
struct range_const_iterator< T[sz] >
struct range_const_iterator_helper< T[sz] >
{
typedef const T* type;
};
@ -64,7 +64,7 @@ struct range_const_iterator< T[sz] >
template<typename C, typename Enabler=void>
struct range_const_iterator
: range_detail::range_const_iterator<
: range_detail::range_const_iterator_helper<
BOOST_DEDUCED_TYPENAME remove_reference<C>::type
>
{

View File

@ -114,6 +114,8 @@ namespace boost
};
} // namespace range_detail
namespace iterators
{
namespace detail
{
// Rationale:
@ -245,8 +247,8 @@ namespace boost
any_iterator_type stored_iterator;
};
}
} //namespace detail
} //namespace iterators
namespace range_detail
{

View File

@ -10,7 +10,7 @@
#ifndef BOOST_RANGE_DETAIL_ANY_ITERATOR_WRAPPER_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_ANY_ITERATOR_WRAPPER_HPP_INCLUDED
#include <boost/polymorphic_cast.hpp>
#include <boost/cast.hpp>
#include <boost/range/config.hpp>
#include <boost/range/detail/any_iterator_interface.hpp>
#include <boost/range/concepts.hpp>

View File

@ -32,7 +32,7 @@ namespace boost
struct range_begin<std_container_>
{
template< typename C >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type fun( C& c )
BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type fun( C& c )
{
return c.begin();
};
@ -46,7 +46,7 @@ namespace boost
struct range_begin<std_pair_>
{
template< typename P >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type fun( const P& p )
BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type fun( const P& p )
{
return p.first;
}
@ -60,7 +60,7 @@ namespace boost
struct range_begin<array_>
{
template<typename T>
static BOOST_RANGE_DEDUCED_TYPENAME range_value<T>::type* fun(T& t)
BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_value<T>::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<C>::type
BOOST_CONSTEXPR inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
begin( C& c )
{
return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );

View File

@ -22,7 +22,6 @@
#ifndef BOOST_RANGE_STRING_COLLECTION_TRAITS_HPP
#define BOOST_RANGE_STRING_COLLECTION_TRAITS_HPP
#include <boost/algorithm/string/config.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_pointer.hpp>
#include <boost/mpl/eval_if.hpp>
@ -74,13 +73,13 @@ namespace boost {
struct collection_traits
{
private:
typedef BOOST_STRING_TYPENAME ::boost::mpl::eval_if<
typedef typename ::boost::mpl::eval_if<
::boost::algorithm::detail::is_pair<T>,
detail::pair_container_traits_selector<T>,
BOOST_STRING_TYPENAME ::boost::mpl::eval_if<
typename ::boost::mpl::eval_if<
::boost::is_array<T>,
detail::array_container_traits_selector<T>,
BOOST_STRING_TYPENAME ::boost::mpl::eval_if<
typename ::boost::mpl::eval_if<
::boost::is_pointer<T>,
detail::pointer_container_traits_selector<T>,
detail::default_container_traits_selector<T>
@ -91,22 +90,22 @@ namespace boost {
//! Function type
typedef container_helper_type function_type;
//! Value type
typedef BOOST_STRING_TYPENAME
typedef typename
container_helper_type::value_type value_type;
//! Size type
typedef BOOST_STRING_TYPENAME
typedef typename
container_helper_type::size_type size_type;
//! Iterator type
typedef BOOST_STRING_TYPENAME
typedef typename
container_helper_type::iterator iterator;
//! Const iterator type
typedef BOOST_STRING_TYPENAME
typedef typename
container_helper_type::const_iterator const_iterator;
//! Result iterator type ( iterator of const_iterator, depending on the constness of the container )
typedef BOOST_STRING_TYPENAME
typedef typename
container_helper_type::result_iterator result_iterator;
//! Difference type
typedef BOOST_STRING_TYPENAME
typedef typename
container_helper_type::difference_type difference_type;
}; // 'collection_traits'
@ -120,7 +119,7 @@ namespace boost {
template< typename C >
struct value_type_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::value_type type;
typedef typename collection_traits<C>::value_type type;
};
//! Container difference trait
@ -130,7 +129,7 @@ namespace boost {
template< typename C >
struct difference_type_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::difference_type type;
typedef typename collection_traits<C>::difference_type type;
};
//! Container iterator trait
@ -140,7 +139,7 @@ namespace boost {
template< typename C >
struct iterator_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::iterator type;
typedef typename collection_traits<C>::iterator type;
};
//! Container const_iterator trait
@ -150,7 +149,7 @@ namespace boost {
template< typename C >
struct const_iterator_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::const_iterator type;
typedef typename collection_traits<C>::const_iterator type;
};
@ -162,7 +161,7 @@ namespace boost {
template< typename C >
struct result_iterator_of
{
typedef BOOST_STRING_TYPENAME collection_traits<C>::result_iterator type;
typedef typename collection_traits<C>::result_iterator type;
};
// collection_traits related functions -----------------------------------------//
@ -172,7 +171,7 @@ namespace boost {
Get the size of the container. Uses collection_traits.
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::size_type
inline typename collection_traits<C>::size_type
size( const C& c )
{
return collection_traits<C>::function_type::size( c );
@ -195,7 +194,7 @@ namespace boost {
Get the begin iterator of the container. Uses collection_traits.
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::iterator
inline typename collection_traits<C>::iterator
begin( C& c )
{
return collection_traits<C>::function_type::begin( c );
@ -206,7 +205,7 @@ namespace boost {
\overload
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::const_iterator
inline typename collection_traits<C>::const_iterator
begin( const C& c )
{
return collection_traits<C>::function_type::begin( c );
@ -217,7 +216,7 @@ namespace boost {
Get the begin iterator of the container. Uses collection_traits.
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::iterator
inline typename collection_traits<C>::iterator
end( C& c )
{
return collection_traits<C>::function_type::end( c );
@ -228,7 +227,7 @@ namespace boost {
\overload
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::const_iterator
inline typename collection_traits<C>::const_iterator
end( const C& c )
{
return collection_traits<C>::function_type::end( c );
@ -241,7 +240,7 @@ namespace boost {
\overload
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::result_iterator
inline typename collection_traits<C>::result_iterator
begin( C& c )
{
return collection_traits<C>::function_type::begin( c );
@ -252,7 +251,7 @@ namespace boost {
\overload
*/
template< typename C >
inline BOOST_STRING_TYPENAME collection_traits<C>::result_iterator
inline typename collection_traits<C>::result_iterator
end( C& c )
{
return collection_traits<C>::function_type::end( c );

View File

@ -10,7 +10,6 @@
#ifndef BOOST_RANGE_STRING_DETAIL_COLLECTION_TRAITS_HPP
#define BOOST_RANGE_STRING_DETAIL_COLLECTION_TRAITS_HPP
#include <boost/algorithm/string/config.hpp>
#include <cstddef>
#include <string>
#include <boost/type_traits/is_array.hpp>
@ -24,7 +23,6 @@
#include <boost/mpl/vector.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/detail/iterator.hpp>
#include <boost/algorithm/string/yes_no_type.hpp>
// Container traits implementation ---------------------------------------------------------
@ -41,16 +39,16 @@ namespace boost {
template< typename ContainerT >
struct default_container_traits
{
typedef BOOST_STRING_TYPENAME ContainerT::value_type value_type;
typedef BOOST_STRING_TYPENAME ContainerT::iterator iterator;
typedef BOOST_STRING_TYPENAME ContainerT::const_iterator const_iterator;
typedef BOOST_STRING_TYPENAME
typedef typename ContainerT::value_type value_type;
typedef typename ContainerT::iterator iterator;
typedef typename ContainerT::const_iterator const_iterator;
typedef typename
::boost::mpl::if_< ::boost::is_const<ContainerT>,
const_iterator,
iterator
>::type result_iterator;
typedef BOOST_STRING_TYPENAME ContainerT::difference_type difference_type;
typedef BOOST_STRING_TYPENAME ContainerT::size_type size_type;
typedef typename ContainerT::difference_type difference_type;
typedef typename ContainerT::size_type size_type;
// static operations
template< typename C >
@ -116,7 +114,10 @@ namespace boost {
};
// Pair container traits ---------------------------------------------------------------------
typedef double yes_type;
typedef char no_type;
// pair selector
template< typename T, typename U >
yes_type is_pair_impl( const std::pair<T,U>* );
@ -135,12 +136,12 @@ namespace boost {
template< typename PairT >
struct pair_container_traits
{
typedef BOOST_STRING_TYPENAME PairT::first_type element_type;
typedef typename PairT::first_type element_type;
typedef BOOST_STRING_TYPENAME ::boost::detail::
typedef typename ::boost::detail::
iterator_traits<element_type>::value_type value_type;
typedef std::size_t size_type;
typedef BOOST_STRING_TYPENAME ::boost::detail::
typedef typename ::boost::detail::
iterator_traits<element_type>::difference_type difference_type;
typedef element_type iterator;
@ -221,7 +222,7 @@ namespace boost {
template< typename TraitsT >
struct array_length
{
typedef BOOST_STRING_TYPENAME
typedef typename
TraitsT::size_type size_type;
BOOST_STATIC_CONSTANT(
@ -249,7 +250,7 @@ namespace boost {
template< typename TraitsT >
struct array_length
{
typedef BOOST_STRING_TYPENAME
typedef typename
TraitsT::size_type size_type;
template< typename A >
@ -276,7 +277,7 @@ namespace boost {
template< typename TraitsT >
struct array_length
{
typedef BOOST_STRING_TYPENAME
typedef typename
TraitsT::size_type size_type;
template< typename A >
@ -304,18 +305,18 @@ namespace boost {
typedef array_traits<T> traits_type;
public:
typedef BOOST_STRING_TYPENAME
typedef typename
traits_type::value_type value_type;
typedef BOOST_STRING_TYPENAME
typedef typename
traits_type::iterator iterator;
typedef BOOST_STRING_TYPENAME
typedef typename
traits_type::const_iterator const_iterator;
typedef BOOST_STRING_TYPENAME
typedef typename
traits_type::size_type size_type;
typedef BOOST_STRING_TYPENAME
typedef typename
traits_type::difference_type difference_type;
typedef BOOST_STRING_TYPENAME
typedef typename
::boost::mpl::if_< ::boost::is_const<T>,
const_iterator,
iterator
@ -323,9 +324,9 @@ namespace boost {
private:
// resolve array size
typedef BOOST_STRING_TYPENAME
typedef typename
::boost::remove_cv<value_type>::type char_type;
typedef BOOST_STRING_TYPENAME
typedef typename
array_length_selector<char_type>::
BOOST_NESTED_TEMPLATE array_length<traits_type> array_length_type;
@ -401,10 +402,10 @@ namespace boost {
template<typename T>
struct pointer_container_traits
{
typedef BOOST_STRING_TYPENAME
typedef typename
::boost::remove_pointer<T>::type value_type;
typedef BOOST_STRING_TYPENAME
typedef typename
::boost::remove_cv<value_type>::type char_type;
typedef ::std::char_traits<char_type> char_traits;
@ -413,7 +414,7 @@ namespace boost {
typedef std::ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef BOOST_STRING_TYPENAME
typedef typename
::boost::mpl::if_< ::boost::is_const<T>,
const_iterator,
iterator

View File

@ -18,7 +18,6 @@
#include <boost/range/config.hpp>
#include <boost/range/detail/sfinae.hpp>
#include <boost/type_traits/is_void.hpp>
#include <boost/type_traits/detail/ice_or.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <cstddef>
@ -70,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::type_traits::ice_or<is_const_char_ptr_, is_const_wchar_t_ptr_>::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<C>::value );
};

View File

@ -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<typename Arg>
R operator()(const Arg& arg) const
{

View File

@ -79,8 +79,8 @@ BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, random_access_traversal
template<class IteratorTraversalTag1, class IteratorTraversalTag2>
struct demote_iterator_traversal_tag
: inner_demote_iterator_traversal_tag<
typename boost::detail::pure_traversal_tag< IteratorTraversalTag1 >::type,
typename boost::detail::pure_traversal_tag< IteratorTraversalTag2 >::type
typename boost::iterators::pure_traversal_tag< IteratorTraversalTag1 >::type,
typename boost::iterators::pure_traversal_tag< IteratorTraversalTag2 >::type
>
{
};

View File

@ -33,7 +33,7 @@ namespace boost
struct range_end<std_container_>
{
template< typename C >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
fun( C& c )
{
return c.end();
@ -48,7 +48,7 @@ namespace boost
struct range_end<std_pair_>
{
template< typename P >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type
BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type
fun( const P& p )
{
return p.second;
@ -63,7 +63,7 @@ namespace boost
struct range_end<array_>
{
template<typename T>
static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t)
BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t)
{
return t + remove_extent<T>::size;
}
@ -74,7 +74,7 @@ namespace boost
namespace range_adl_barrier
{
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
BOOST_CONSTEXPR inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
end( C& c )
{
return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );

View File

@ -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;
}

View File

@ -153,8 +153,12 @@ template<typename Iterator1
typename iterator_reference<Iterator2>::type
>::type
>::value,
typename add_const<
typename iterator_reference<Iterator1>::type
typename add_reference<
typename add_const<
typename remove_reference<
typename iterator_reference<Iterator1>::type
>::type
>::type
>::type,
typename iterator_reference<Iterator1>::type
>::type

View File

@ -15,20 +15,32 @@
# pragma once
#endif
#include <boost/mpl/and.hpp>
#include <boost/range/config.hpp>
#include <boost/range/iterator.hpp>
#include <boost/range/has_range_iterator.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/type_traits/remove_reference.hpp>
namespace boost
{
namespace range_detail
{
template< class T, bool B = has_type<range_iterator<T> >::value >
struct range_difference
{ };
template< class T >
struct range_difference<T, true>
: iterator_difference<
BOOST_DEDUCED_TYPENAME range_iterator<T>::type
>
{ };
}
template< class T >
struct range_difference
: iterator_difference<
BOOST_DEDUCED_TYPENAME range_iterator<
BOOST_DEDUCED_TYPENAME remove_reference<T>::type
>::type
>
: range_detail::range_difference<BOOST_DEDUCED_TYPENAME remove_reference<T>::type>
{ };
}

View File

@ -15,18 +15,19 @@
# pragma once
#endif
#include <boost/iterator/distance.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/difference_type.hpp>
namespace boost
namespace boost
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_difference<T>::type
inline BOOST_CXX14_CONSTEXPR BOOST_DEDUCED_TYPENAME range_difference<T>::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'

View File

@ -37,7 +37,7 @@ namespace range_detail
// primary template
//////////////////////////////////////////////////////////////////////
template< typename C >
inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
range_end( C& c )
{
//
@ -53,13 +53,13 @@ namespace range_detail
//////////////////////////////////////////////////////////////////////
template< typename Iterator >
inline Iterator range_end( const std::pair<Iterator,Iterator>& p )
BOOST_CONSTEXPR inline Iterator range_end( const std::pair<Iterator,Iterator>& p )
{
return p.second;
}
template< typename Iterator >
inline Iterator range_end( std::pair<Iterator,Iterator>& p )
BOOST_CONSTEXPR inline Iterator range_end( std::pair<Iterator,Iterator>& 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<T,sz>( 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<T,sz>( a );
}
@ -88,7 +88,7 @@ namespace range_adl_barrier
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator<T>::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<T>::type end( T& r )
}
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::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<const T>::type
BOOST_CONSTEXPR inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
const_end( const T& r )
{
return boost::range_adl_barrier::end( r );

View File

@ -37,9 +37,9 @@ namespace boost
T,
BOOST_DEDUCED_TYPENAME ::boost::enable_if<
BOOST_DEDUCED_TYPENAME mpl::eval_if<is_const<T>,
has_type<range_const_iterator<
has_type<boost::range_const_iterator<
BOOST_DEDUCED_TYPENAME remove_const<T>::type> >,
has_type<range_mutable_iterator<T> >
has_type<boost::range_mutable_iterator<T> >
>::type
>::type
>
@ -57,7 +57,7 @@ namespace boost
struct has_range_const_iterator_impl<
T,
BOOST_DEDUCED_TYPENAME ::boost::enable_if<
has_type<range_const_iterator<T> >
has_type<boost::range_const_iterator<T> >
>::type
>
: boost::mpl::true_

View File

@ -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<Integer> iterator_t;
const std::ptrdiff_t sz = static_cast<std::ptrdiff_t>(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<Integer>(
iterator_t(first, 0, step_size),
iterator_t(first, num_steps, step_size));
}
template<typename Integer>
integer_range<Integer>
irange(Integer last)
{
return integer_range<Integer>(static_cast<Integer>(0), last);
}
} // namespace boost
#endif // include guard

View File

@ -46,31 +46,29 @@ namespace boost
};
}
#endif
template< typename C, typename Enabler=void >
struct range_iterator
{
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
typedef BOOST_RANGE_DEDUCED_TYPENAME
range_detail_vc7_1::range_iterator<C>::type type;
#else
private:
typedef typename remove_reference<C>::type param_t;
public:
typedef typename mpl::eval_if_c<
is_const<param_t>::value,
range_const_iterator<typename remove_const<param_t>::type>,
range_mutable_iterator<param_t>
>::type type;
#endif
};
#else
template< typename C, typename Enabler=void >
struct range_iterator
: mpl::if_c<
is_const<typename remove_reference<C>::type>::value,
range_const_iterator<typename remove_const<typename remove_reference<C>::type>::type>,
range_mutable_iterator<typename remove_reference<C>::type>
>::type
{
};
#endif
} // namespace boost
#endif

View File

@ -66,13 +66,13 @@ namespace boost
template< class ForwardRange >
static IteratorT adl_begin( ForwardRange& r )
{
return static_cast<IteratorT>( boost::begin( r ) );
return IteratorT( boost::begin( r ) );
}
template< class ForwardRange >
static IteratorT adl_end( ForwardRange& r )
{
return static_cast<IteratorT>( boost::end( r ) );
return IteratorT( boost::end( r ) );
}
};
@ -442,8 +442,8 @@ public:
> base_type;
template<class Source>
struct is_compatible_range
: is_convertible<
struct is_compatible_range_
: is_convertible<
BOOST_DEDUCED_TYPENAME mpl::eval_if<
has_range_iterator<Source>,
range_iterator<Source>,
@ -454,6 +454,20 @@ public:
{
};
template<class Source>
struct is_compatible_range
: mpl::and_<
mpl::not_<
is_convertible<
Source,
BOOST_DEDUCED_TYPENAME base_type::iterator
>
>,
is_compatible_range_<Source>
>
{
};
protected:
typedef iterator_range_detail::iterator_range_impl<IteratorT> impl;

View File

@ -54,11 +54,20 @@ namespace boost
inline typename range_size<const SinglePassRange>::type
size(const SinglePassRange& rng)
{
// Very strange things happen on some compilers that have the range concept
// asserts disabled. This preprocessor condition is clearly redundant on a
// working compiler but is vital for at least some compilers such as clang 4.2
// but only on the Mac!
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT == 1
BOOST_RANGE_CONCEPT_ASSERT((boost::SinglePassRangeConcept<SinglePassRange>));
#endif
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
!BOOST_WORKAROUND(__GNUC__, < 3) \
/**/
using namespace range_detail;
#endif
return range_calculate_size(rng);
}

View File

@ -18,6 +18,7 @@
#include <boost/range/config.hpp>
#include <boost/range/difference_type.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/has_range_iterator.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/make_unsigned.hpp>
@ -51,7 +52,7 @@ namespace boost
};
template<typename C, typename Enabler=void>
struct range_size
struct range_size_
{
typedef BOOST_DEDUCED_TYPENAME make_unsigned<
BOOST_DEDUCED_TYPENAME range_difference<C>::type
@ -59,7 +60,7 @@ namespace boost
};
template<typename C>
struct range_size<
struct range_size_<
C,
BOOST_DEDUCED_TYPENAME ::boost::enable_if<has_size_type<C>, void>::type
>
@ -67,29 +68,20 @@ namespace boost
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
};
template<typename C, bool B = range_detail::has_type< range_iterator<C> >::value>
struct range_size
{ };
template<typename C>
struct range_size<C, true>
: range_size_<C>
{ };
}
template< class T >
struct range_size :
detail::range_size<T>
{
// Very strange things happen on some compilers that have the range concept
// asserts disabled. This preprocessor condition is clearly redundant on a
// working compiler but is vital for at least some compilers such as clang 4.2
// but only on the Mac!
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT == 1
BOOST_RANGE_CONCEPT_ASSERT((boost::SinglePassRangeConcept<T>));
#endif
};
template< class T >
struct range_size<const T >
: detail::range_size<T>
{
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT == 1
BOOST_RANGE_CONCEPT_ASSERT((boost::SinglePassRangeConcept<T>));
#endif
};
{ };
} // namespace boost

View File

@ -182,8 +182,8 @@ public:
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) )
sub_range(const sub_range& r)
: base(impl::adl_begin(static_cast<const base&>(r)),
impl::adl_end(static_cast<const base&>(r)))
: base(impl::adl_begin(const_cast<base&>(static_cast<const base&>(r))),
impl::adl_end(const_cast<base&>(static_cast<const base&>(r))))
{ }
#endif

16
meta/libraries.json Normal file
View File

@ -0,0 +1,16 @@
{
"key": "range",
"name": "Range",
"authors": [
"Niel Groves",
"Thorsten Ottosen"
],
"description": "A new infrastructure for generic algorithms that builds on top of the new iterator concepts.",
"category": [
"Algorithms"
],
"maintainers": [
"Neil Groves <neilgroves -at- googlemail.com>",
"Nathan Ridge <zeratul976 -at- hotmail.com>"
]
}

View File

@ -40,10 +40,6 @@ test-suite range :
[ compile-fail compile_fail/adaptor/copied_concept2.cpp ]
[ compile-fail compile_fail/adaptor/copied_concept3.cpp ]
[ compile-fail compile_fail/adaptor/copied_concept4.cpp ]
[ compile-fail compile_fail/adaptor/filtered_concept.cpp ]
[ compile-fail compile_fail/adaptor/filtered_concept2.cpp ]
[ compile-fail compile_fail/adaptor/filtered_concept3.cpp ]
[ compile-fail compile_fail/adaptor/filtered_concept4.cpp ]
[ compile-fail compile_fail/adaptor/reversed_concept.cpp ]
[ compile-fail compile_fail/adaptor/reversed_concept2.cpp ]
[ compile-fail compile_fail/adaptor/reversed_concept3.cpp ]
@ -63,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 ]
@ -219,6 +217,7 @@ test-suite range :
[ range-test ticket_5811_indirected_optional ]
[ range-test ticket_6715_iterator_range_equality ]
[ range-test ticket_6944 ]
[ range-test ticket_10336 ]
[ range-test value_type ]
;

View File

@ -21,6 +21,7 @@
#include <set>
#include <string>
#include <vector>
#include <sstream>
namespace boost
{
@ -50,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 )
{
@ -85,32 +103,75 @@ 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()
{
std::vector<int> v;
std::string str("0 1 2 3 4 5");
std::istringstream in(str);
boost::push_back(v,
boost::make_iterator_range(
std::istream_iterator<int>(in),
std::istream_iterator<int>())
| boost::adaptors::filtered(is_even()));
std::vector<int> reference;
for (int i = 0; i < 6; i += 2)
{
reference.push_back(i);
}
BOOST_CHECK_EQUAL_COLLECTIONS(
reference.begin(), reference.end(),
v.begin(), v.end());
}
void filtered_test()
@ -119,6 +180,7 @@ namespace boost
filtered_test_all_predicates< std::list< int > >();
filtered_test_all_predicates< std::set< int > >();
filtered_test_all_predicates< std::multiset< int > >();
ticket_10988_single_pass();
}
}
}

View File

@ -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 <boost/range/adaptor/ref_unwrapped.hpp>
#define BOOST_TEST_MAIN
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include <vector>
#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<std::reference_wrapper<int>> input_values{one, two, three};
const std::vector<int*> expected{&one, &two, &three};
std::vector<int*> 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<std::reference_wrapper<int>> input_values{one, two, three};
const std::vector<int*> expected{&one, &two, &three};
std::vector<int*> 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<std::reference_wrapper<const int>> input_values{one, two, three};
const std::vector<const int*> expected{&one, &two, &three};
std::vector<const int*> 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

View File

@ -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 <boost/range/adaptor/ref_unwrapped.hpp>
#include <iostream>
#include <vector>
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<std::reference_wrapper<example> > input{one, two, three};
for (auto&& entry : input | ref_unwrapped)
{
std::cout << entry.value;
}
return 0;
//<-
#endif
//->
}
//]

View File

@ -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.

View File

@ -38,6 +38,24 @@ namespace boost
int operator()(int x) const { return x / 2; }
};
struct lambda_init
{
};
struct lambda
{
typedef int result_type;
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 +77,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 +111,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()

View File

@ -457,7 +457,7 @@ void simple_compile_test()
BOOST_RANGE_RETURNS_TEST2( find_end, v, std::less<int>() );
BOOST_RANGE_RETURNS_TEST2( find_first_of, v, std::less<int>() );
BOOST_RANGE_RETURNS_TEST2( search, v, std::less<int>() );
BOOST_RANGE_RETURNS_TEST2( boost::search, v, std::less<int>() );
BOOST_RANGE_RETURNS_TEST2( lower_bound, 0, std::less<int>() );
BOOST_RANGE_RETURNS_TEST2( upper_bound, 0, std::less<int>() );

View File

@ -19,6 +19,7 @@
#include <list>
#include <vector>
namespace
{
template< class Container >
@ -58,6 +59,76 @@ namespace
test_push_back_impl< std::vector<std::size_t> >();
test_push_back_impl< std::list<std::size_t> >();
}
#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<noncopyable_int> >();
test_push_back_move_impl< std::list<noncopyable_int> >();
}
#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;
}

View File

@ -1,38 +0,0 @@
// Boost.Range library
//
// Copyright Neil Groves 2014. 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 "mock_range.hpp"
#include <boost/range/adaptor/filtered.hpp>
namespace
{
struct always_true
{
typedef bool result_type;
bool operator()(int) const
{
return true;
}
};
} // anonymous namespace
int main(int, const char**)
{
using boost::range::unit_test::mock_range;
using boost::adaptors::filtered;
// This next line should fail when Boost.Range concept checking is
// enabled since the filtered adaptor takes at least a ForwardRange.
return (mock_range<boost::single_pass_traversal_tag>() |
filtered(always_true())).front();
}

View File

@ -1,38 +0,0 @@
// Boost.Range library
//
// Copyright Neil Groves 2014. 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 "mock_range.hpp"
#include <boost/range/adaptor/filtered.hpp>
namespace
{
struct always_true
{
typedef bool result_type;
bool operator()(int) const
{
return true;
}
};
} // anonymous namespace
int main(int, const char**)
{
using boost::range::unit_test::mock_const_range;
using boost::adaptors::filtered;
// This next line should fail when Boost.Range concept checking is
// enabled since the filtered adaptor takes at least a ForwardRange.
return (mock_const_range<boost::single_pass_traversal_tag>() |
filtered(always_true())).front();
}

View File

@ -1,38 +0,0 @@
// Boost.Range library
//
// Copyright Neil Groves 2014. 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 "mock_range.hpp"
#include <boost/range/adaptor/filtered.hpp>
namespace
{
struct always_true
{
typedef bool result_type;
bool operator()(int) const
{
return true;
}
};
} // anonymous namespace
int main(int, const char**)
{
using boost::range::unit_test::mock_range;
// This next line should fail when Boost.Range concept checking is
// enabled since the filtered adaptor takes at least a ForwardRange.
return boost::adaptors::filter(
mock_range<boost::single_pass_traversal_tag>(),
always_true()).front();
}

View File

@ -1,38 +0,0 @@
// Boost.Range library
//
// Copyright Neil Groves 2014. 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 "mock_range.hpp"
#include <boost/range/adaptor/filtered.hpp>
namespace
{
struct always_true
{
typedef bool result_type;
bool operator()(int) const
{
return true;
}
};
} // anonymous namespace
int main(int, const char**)
{
using boost::range::unit_test::mock_const_range;
// This next line should fail when Boost.Range concept checking is
// enabled since the filtered adaptor takes at least a ForwardRange.
return boost::adaptors::filter(
mock_const_range<boost::single_pass_traversal_tag>(),
always_true()).front();
}

View File

@ -18,6 +18,23 @@
namespace boost
{
// Test an integer range with a step size of 1.
template<typename Integer>
void test_irange_impl(Integer last)
{
std::vector<Integer> reference;
for (Integer i = static_cast<Integer>(0); i < last; ++i)
{
reference.push_back(i);
}
std::vector<Integer> 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<typename Integer>
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<typename Integer, typename IntegerInput>
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<IntegerInput>(static_cast<Integer>(first)) != first)
|| (static_cast<IntegerInput>(static_cast<Integer>(last)) != last))
return;
std::vector<Integer> reference;
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;
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;
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<signed char>(last);
test_irange_impl<unsigned char>(last);
test_irange_impl<signed short>(last);
test_irange_impl<unsigned short>(last);
test_irange_impl<signed int>(last);
test_irange_impl<unsigned int>(last);
test_irange_impl<signed long>(last);
test_irange_impl<unsigned long>(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);

View File

@ -22,6 +22,8 @@
#include <boost/type_traits.hpp>
#include <boost/test/test_tools.hpp>
#include <vector>
#include <iterator>
#include <utility>
void check_iterator_pair()
{
@ -39,23 +41,23 @@ void check_iterator_pair()
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value<pair_t>::type,
boost::detail::iterator_traits<pair_t::first_type>::value_type>::value ));
std::iterator_traits<pair_t::first_type>::value_type>::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<pair_t>::type, pair_t::first_type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_const_iterator<pair_t>::type, pair_t::first_type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference<pair_t>::type,
boost::detail::iterator_traits<pair_t::first_type>::difference_type >::value ));
std::iterator_traits<pair_t::first_type>::difference_type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size<pair_t>::type, std::size_t >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<pair_t>::type, pair_t::first_type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const_pair_t>::type, const_pair_t::first_type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_value<const_pair_tt>::type,
boost::detail::iterator_traits<const_pair_t::first_type>::value_type>::value ));
std::iterator_traits<const_pair_t::first_type>::value_type>::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
//
// This behavior is not supported with v2.
//BOOST_STATIC_ASSERT(( is_same< range_const_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_difference<const_pair_tt>::type,
boost::detail::iterator_traits<const_pair_tt::first_type>::difference_type >::value ));
std::iterator_traits<const_pair_tt::first_type>::difference_type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_size<const_pair_tt>::type, std::size_t >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));
BOOST_STATIC_ASSERT(( boost::is_same< boost::range_iterator<const_pair_tt>::type, const_pair_tt::first_type >::value ));

View File

@ -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 ) ) );
@ -266,21 +266,18 @@ inline void test_advance()
BOOST_CHECK_EQUAL(r3.advance_end(-1).size(), 1u);
}
boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] )
struct ptr_iterator
: boost::iterator_adaptor<ptr_iterator, int *>
{
boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
ptr_iterator() {}
ptr_iterator(int *p) : boost::iterator_adaptor<ptr_iterator, int *>(p) {}
private:
typedef void iterator; // To throw off the SFINAE mechanism in iterator_range
};
test->add(BOOST_TEST_CASE(&check_iterator_range));
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::less>));
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::less_or_equal>));
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::greater>));
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::greater_or_equal>));
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::equal_to>));
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::not_equal_to>));
test->add(BOOST_TEST_CASE(&iterator_range_test_detail::check_make_iterator_range_n));
test->add(BOOST_TEST_CASE(&test_advance));
return test;
void test_sfinae()
{
boost::iterator_range<ptr_iterator> r(ptr_iterator(0), ptr_iterator(0));
}
//
@ -313,3 +310,21 @@ void check_reference_type()
test_iter_range<veci_type>(a_vec);
test_iter_range<veci_type const>(a_vec);
}
boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] )
{
boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
test->add(BOOST_TEST_CASE(&check_iterator_range));
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::less>));
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::less_or_equal>));
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::greater>));
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::greater_or_equal>));
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::equal_to>));
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::not_equal_to>));
test->add(BOOST_TEST_CASE(&iterator_range_test_detail::check_make_iterator_range_n));
test->add(BOOST_TEST_CASE(&test_advance));
return test;
}

View File

@ -277,6 +277,7 @@ namespace boost
std::vector<int> v2;
std::vector<int> joined;
boost::push_back(joined, join(v1, v2));
boost::push_back(joined, join(v2, v1));
}
namespace trac7376

View File

@ -244,6 +244,22 @@ inline void test_advance()
BOOST_CHECK_EQUAL(r3.advance_end(-1).size(), 1u);
}
void ticket_10514()
{
typedef std::vector<int> vec_t;
typedef boost::sub_range<vec_t> range_t;
vec_t v(10);
range_t r(v.begin(), v.end());
const range_t& cr = r;
range_t copy_r = cr;
BOOST_CHECK(r.begin() == copy_r.begin());
BOOST_CHECK(r.end() == copy_r.end());
BOOST_CHECK(cr.begin() == copy_r.begin());
BOOST_CHECK(cr.end() == copy_r.end());
}
} // anonymous namespace
} // namespace boost_range_test
@ -262,6 +278,8 @@ boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
test->add(BOOST_TEST_CASE(&boost_range_test::test_advance));
test->add(BOOST_TEST_CASE(&boost_range_test::ticket_10514));
return test;
}

43
test/ticket_10336.cpp Normal file
View File

@ -0,0 +1,43 @@
// Boost.Range library
//
// Copyright Neil Groves 2011. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// For more information, see http://www.boost.org/libs/range/
//
#include <boost/range/iterator_range.hpp>
#include <boost/unordered_map.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
namespace boost
{
namespace
{
// Ticket 10336 - compilation error in iterator_range and unordered_map
void test_ticket_10336()
{
typedef boost::unordered_map<int,int> container_t;
typedef container_t::const_iterator citer_t;
typedef boost::iterator_range<citer_t> rng_t;
const container_t c;
rng_t rng(c.begin(), c.end());
}
}
}
boost::unit_test::test_suite*
init_unit_test_suite(int argc, char* argv[])
{
boost::unit_test::test_suite* test
= BOOST_TEST_SUITE( "RangeTestSuite.ticket_10336" );
test->add( BOOST_TEST_CASE( &boost::test_ticket_10336 ) );
return test;
}

View File

@ -14,7 +14,6 @@
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include <functional>
#include <vector>
namespace boost
@ -22,9 +21,12 @@ namespace boost
namespace
{
class TestTicket5486Pred
: public std::binary_function<int,int,bool>
{
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: