mirror of
https://github.com/boostorg/range.git
synced 2025-07-25 02:17:29 +02:00
Compare commits
102 Commits
boost-1.62
...
boost-1.73
Author | SHA1 | Date | |
---|---|---|---|
77a4dd5124 | |||
4ec46acdf5 | |||
cecebeea51 | |||
802fda6701 | |||
4ad147a220 | |||
eced0cfac8 | |||
9f94c8703b | |||
023f45be01 | |||
364f755d99 | |||
af9f65e06e | |||
b91cb90dca | |||
7efe3c68f6 | |||
357bf3b980 | |||
9192996a93 | |||
4cfd4d8287 | |||
70d1727ed3 | |||
406226eccd | |||
05532829bd | |||
c24661a636 | |||
314b5d6b3c | |||
4dd5ad0f64 | |||
f1906e914e | |||
795046f8fc | |||
2aaa802e6a | |||
5b2500872d | |||
b1d5d23514 | |||
aaebfa5b20 | |||
95a62a3b3a | |||
67929cd7df | |||
5408f220dd | |||
937a411c3f | |||
1dac6a796e | |||
1234c59a39 | |||
e0d2e492a1 | |||
619c074146 | |||
4614777aaf | |||
83a352fa58 | |||
0e0d77cfab | |||
d1f36fba8d | |||
4283443532 | |||
3771624560 | |||
4a729678fd | |||
dfa3697764 | |||
efdd98332b | |||
8b98b696ff | |||
97951d2a8b | |||
efa2dc71f9 | |||
d99628981d | |||
e65434eb4f | |||
93513a3801 | |||
93eb91e63e | |||
f3a4246bd9 | |||
796080bbb8 | |||
370f1a4cd2 | |||
7d564572e2 | |||
9afc3bcbe2 | |||
69409ed63a | |||
23e5801e2a | |||
e476e1900a | |||
452b1bb7e7 | |||
7b89c747d6 | |||
deb3ae9800 | |||
56d470635d | |||
5c70a54597 | |||
f829c55c72 | |||
910fc7bf82 | |||
67c18ac1f1 | |||
5787c56994 | |||
9e5680b590 | |||
1b4f8100ef | |||
7567dce0c1 | |||
e48b9c38e7 | |||
283b8beddc | |||
4ce15f9b52 | |||
bb43887430 | |||
5a37aa4e98 | |||
5196baa1b0 | |||
1947daf1b5 | |||
7ca999c662 | |||
e7ebe14707 | |||
3225aaf82b | |||
262c0f96b3 | |||
1a3aeeb336 | |||
78a8f5bf3d | |||
9bf860fd30 | |||
64c83341ab | |||
6241dc62aa | |||
f83381d938 | |||
926318105e | |||
140866b402 | |||
490ba3fdcd | |||
e4f456d438 | |||
adcb071dc6 | |||
7fad9837fb | |||
11dbb1cb5a | |||
e961e66909 | |||
8847fd63cb | |||
62941f740d | |||
0c930a3697 | |||
09084d6355 | |||
9ca1622dd0 | |||
474c62ab16 |
151
.travis.yml
Normal file
151
.travis.yml
Normal file
@ -0,0 +1,151 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
python: "2.7"
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- develop
|
||||
- /feature\/.*/
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BOGUS_JOB=true
|
||||
|
||||
matrix:
|
||||
|
||||
exclude:
|
||||
- env: BOGUS_JOB=true
|
||||
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.4
|
||||
env: TOOLSET=gcc-4.4 CXXSTD=98,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.4
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.6
|
||||
env: TOOLSET=gcc-4.6 CXXSTD=03,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc-5 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc-5 CXXSTD=14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc-6 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc-6 CXXSTD=14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc-7 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc-7 CXXSTD=14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang CXXSTD=14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang CXXSTD=03,11
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang CXXSTD=14,1z
|
||||
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
- cd ..
|
||||
- git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule update --init tools/build
|
||||
- git submodule update --init libs/config
|
||||
- git submodule update --init tools/boostdep
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/range
|
||||
- python tools/boostdep/depinst/depinst.py range
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
|
||||
script:
|
||||
- ./b2 -j 3 libs/range/test toolset=$TOOLSET cxxstd=$CXXSTD
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: always
|
@ -28,3 +28,8 @@ boostbook quickbook
|
||||
<format>pdf:<xsl:param>img.src.path=$(images_location)/
|
||||
;
|
||||
|
||||
###############################################################################
|
||||
alias boostdoc ;
|
||||
explicit boostdoc ;
|
||||
alias boostrelease : quickbook ;
|
||||
explicit boostrelease ;
|
||||
|
@ -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
|
||||
|
||||
|
@ -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__]]
|
||||
|
@ -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]
|
||||
|
32
doc/reference/adaptors/ref_unwrapped.qbk
Normal file
32
doc/reference/adaptors/ref_unwrapped.qbk
Normal 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]
|
@ -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:]
|
||||
|
@ -13,14 +13,14 @@ template<
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_iterator<ForwardRange>::type
|
||||
remove(ForwardRange& rng, UnaryPredicate pred);
|
||||
remove_if(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
class ForwardRange,
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_iterator<const ForwardRange>::type
|
||||
remove(const ForwardRange& rng, UnaryPredicate pred);
|
||||
remove_if(const ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
@ -28,7 +28,7 @@ template<
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<ForwardRange,re>::type
|
||||
remove(ForwardRange& rng, UnaryPredicate pred);
|
||||
remove_if(ForwardRange& rng, UnaryPredicate pred);
|
||||
|
||||
template<
|
||||
range_return_value re,
|
||||
@ -36,7 +36,7 @@ template<
|
||||
class UnaryPredicate
|
||||
>
|
||||
typename range_return<const ForwardRange,re>::type
|
||||
remove(const ForwardRange& rng, UnaryPredicate pred);
|
||||
remove_if(const ForwardRange& rng, UnaryPredicate pred);
|
||||
``
|
||||
|
||||
[heading Description]
|
||||
|
@ -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]
|
||||
|
||||
|
@ -354,7 +354,7 @@ int main(int, const char*[])
|
||||
char tc;
|
||||
BOOST_FOREACH(boost::tie(ti, tc), boost::combine(v, l))
|
||||
{
|
||||
std::cout << '(' << ti << ',' << tv << ')' << '\n';
|
||||
std::cout << '(' << ti << ',' << tc << ')' << '\n';
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -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 )
|
||||
{
|
||||
|
102
include/boost/range/adaptor/ref_unwrapped.hpp
Normal file
102
include/boost/range/adaptor/ref_unwrapped.hpp
Normal 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 <boost/type_traits/declval.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;
|
||||
|
||||
typedef decltype( boost::declval<argument_type>().get() ) result_type;
|
||||
|
||||
result_type operator()( argument_type &&r ) const
|
||||
{
|
||||
return r.get();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class SinglePassRange>
|
||||
class unwrap_ref_range
|
||||
: public transformed_range<unwrap_ref<SinglePassRange>,
|
||||
SinglePassRange>
|
||||
{
|
||||
typedef transformed_range<unwrap_ref<SinglePassRange>,
|
||||
SinglePassRange> base;
|
||||
public:
|
||||
typedef unwrap_ref<SinglePassRange> transform_fn_type;
|
||||
typedef SinglePassRange source_range_type;
|
||||
|
||||
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
|
@ -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>));
|
||||
|
@ -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>));
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <boost/range/size_type.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Copyright 2019 Glen Joseph Fernandes (glenjofe@gmail.com)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
@ -13,14 +14,35 @@
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
#include <boost/range/detail/less.hpp>
|
||||
#include <boost/range/detail/range_return.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename Iterator, class Predicate>
|
||||
inline Iterator
|
||||
max_element(Iterator first, Iterator last, Predicate comp)
|
||||
{
|
||||
if (first == last) {
|
||||
return last;
|
||||
}
|
||||
Iterator result = first;
|
||||
while (++first != last) {
|
||||
if (comp(*result, *first)) {
|
||||
result = first;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// \brief template function max_element
|
||||
///
|
||||
/// range-based version of the max_element std algorithm
|
||||
@ -32,7 +54,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 detail::max_element(boost::begin(rng), boost::end(rng), detail::less());
|
||||
}
|
||||
|
||||
/// \overload
|
||||
@ -41,7 +63,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 detail::max_element(boost::begin(rng), boost::end(rng), detail::less());
|
||||
}
|
||||
|
||||
/// \overload
|
||||
@ -50,7 +72,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 detail::max_element(boost::begin(rng), boost::end(rng), pred);
|
||||
}
|
||||
|
||||
/// \overload
|
||||
@ -59,7 +81,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 detail::max_element(boost::begin(rng), boost::end(rng), pred);
|
||||
}
|
||||
|
||||
// range_return overloads
|
||||
@ -71,7 +93,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)),
|
||||
detail::max_element(boost::begin(rng), boost::end(rng), detail::less()),
|
||||
rng);
|
||||
}
|
||||
|
||||
@ -82,7 +104,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)),
|
||||
detail::max_element(boost::begin(rng), boost::end(rng), detail::less()),
|
||||
rng);
|
||||
}
|
||||
|
||||
@ -93,7 +115,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),
|
||||
detail::max_element(boost::begin(rng), boost::end(rng), pred),
|
||||
rng);
|
||||
}
|
||||
|
||||
@ -104,7 +126,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),
|
||||
detail::max_element(boost::begin(rng), boost::end(rng), pred),
|
||||
rng);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
// Copyright 2019 Glen Joseph Fernandes (glenjofe@gmail.com)
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
@ -13,14 +14,35 @@
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
#include <boost/range/detail/less.hpp>
|
||||
#include <boost/range/detail/range_return.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename Iterator, class Predicate>
|
||||
inline Iterator
|
||||
min_element(Iterator first, Iterator last, Predicate comp)
|
||||
{
|
||||
if (first == last) {
|
||||
return last;
|
||||
}
|
||||
Iterator result = first;
|
||||
while (++first != last) {
|
||||
if (comp(*first, *result)) {
|
||||
result = first;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// \brief template function min_element
|
||||
///
|
||||
/// range-based version of the min_element std algorithm
|
||||
@ -32,7 +54,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 detail::min_element(boost::begin(rng), boost::end(rng), detail::less());
|
||||
}
|
||||
|
||||
/// \overload
|
||||
@ -41,7 +63,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 detail::min_element(boost::begin(rng), boost::end(rng), detail::less());
|
||||
}
|
||||
|
||||
/// \overload
|
||||
@ -50,7 +72,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 detail::min_element(boost::begin(rng), boost::end(rng), pred);
|
||||
}
|
||||
|
||||
/// \overload
|
||||
@ -59,7 +81,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 detail::min_element(boost::begin(rng), boost::end(rng), pred);
|
||||
}
|
||||
|
||||
// range_return overloads
|
||||
@ -71,7 +93,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)),
|
||||
detail::min_element(boost::begin(rng), boost::end(rng), detail::less()),
|
||||
rng);
|
||||
}
|
||||
|
||||
@ -82,7 +104,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)),
|
||||
detail::min_element(boost::begin(rng), boost::end(rng), detail::less()),
|
||||
rng);
|
||||
}
|
||||
|
||||
@ -93,7 +115,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),
|
||||
detail::min_element(boost::begin(rng), boost::end(rng), pred),
|
||||
rng);
|
||||
}
|
||||
|
||||
@ -104,7 +126,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),
|
||||
detail::min_element(boost::begin(rng), boost::end(rng), pred),
|
||||
rng);
|
||||
}
|
||||
|
||||
|
@ -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 BOOST_CONSTEXPR result_type (min)()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOST_CONSTEXPR 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 BOOST_CONSTEXPR result_type (min)()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOST_CONSTEXPR 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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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* )
|
||||
{
|
||||
|
@ -22,6 +22,8 @@
|
||||
#else
|
||||
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -36,7 +38,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 +54,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 +73,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,6 +96,9 @@ namespace range_adl_barrier
|
||||
{
|
||||
|
||||
template< class T >
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
BOOST_CONSTEXPR
|
||||
#endif
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type begin( T& r )
|
||||
{
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
@ -103,6 +108,9 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type begin( T& r )
|
||||
}
|
||||
|
||||
template< class T >
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
BOOST_CONSTEXPR
|
||||
#endif
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
|
||||
{
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
|
@ -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:
|
||||
@ -250,7 +252,7 @@ namespace boost {
|
||||
n = i - j;
|
||||
}
|
||||
private:
|
||||
BOOST_DEDUCED_TYPENAME RandomAccessIteratorConcept::difference_type n;
|
||||
BOOST_DEDUCED_TYPENAME BidirectionalIteratorConcept<Iterator>::difference_type n;
|
||||
Iterator i;
|
||||
Iterator j;
|
||||
#endif
|
||||
|
@ -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 );
|
||||
|
@ -18,10 +18,8 @@
|
||||
#include <boost/range/config.hpp>
|
||||
#include <boost/range/detail/sfinae.hpp>
|
||||
#include <boost/type_traits/is_void.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -71,7 +69,7 @@ namespace boost
|
||||
BOOST_STATIC_CONSTANT( bool, is_const_wchar_t_ptr_ = sizeof( boost::range_detail::is_const_wchar_t_ptr_impl( ptr ) ) == sizeof( yes_type ) );
|
||||
BOOST_STATIC_CONSTANT( bool, is_char_array_ = sizeof( boost::range_detail::is_char_array_impl( ptr ) ) == sizeof( yes_type ) );
|
||||
BOOST_STATIC_CONSTANT( bool, is_wchar_t_array_ = sizeof( boost::range_detail::is_wchar_t_array_impl( ptr ) ) == sizeof( yes_type ) );
|
||||
BOOST_STATIC_CONSTANT( bool, is_string_ = (boost::mpl::or_<boost::mpl::bool_<is_const_char_ptr_>, boost::mpl::bool_<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 );
|
||||
|
||||
};
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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 );
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
26
include/boost/range/detail/less.hpp
Normal file
26
include/boost/range/detail/less.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_RANGE_DETAIL_LESS
|
||||
#define BOOST_RANGE_DETAIL_LESS
|
||||
|
||||
namespace boost {
|
||||
namespace range {
|
||||
namespace detail {
|
||||
|
||||
struct less {
|
||||
template<class T, class U>
|
||||
bool operator()(const T& lhs, const U& rhs) const {
|
||||
return lhs < rhs;
|
||||
}
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
} /* range */
|
||||
} /* boost */
|
||||
|
||||
#endif
|
@ -58,6 +58,7 @@
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/utility/enable_if.hpp> // disable_if
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
#if !defined(BOOST_RANGE_DETAIL_MICROSOFT_RANGE_VERSION_1)
|
||||
#include <boost/range/mutable_iterator.hpp>
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
@ -15,20 +15,26 @@
|
||||
# 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
|
||||
distance( const T& r )
|
||||
namespace range_distance_adl_barrier
|
||||
{
|
||||
return std::distance( boost::begin( r ), boost::end( r ) );
|
||||
template< class T >
|
||||
inline BOOST_CXX14_CONSTEXPR BOOST_DEDUCED_TYPENAME range_difference<T>::type
|
||||
distance( const T& r )
|
||||
{
|
||||
return boost::iterators::distance( boost::begin( r ), boost::end( r ) );
|
||||
}
|
||||
}
|
||||
|
||||
using namespace range_distance_adl_barrier;
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#endif
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/const_iterator.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -37,7 +39,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 +55,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 +71,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,6 +90,9 @@ namespace range_adl_barrier
|
||||
{
|
||||
|
||||
template< class T >
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
BOOST_CONSTEXPR
|
||||
#endif
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
|
||||
{
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
@ -97,6 +102,9 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
|
||||
}
|
||||
|
||||
template< class T >
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 40700)
|
||||
BOOST_CONSTEXPR
|
||||
#endif
|
||||
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
|
||||
{
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
||||
@ -115,7 +123,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 );
|
||||
|
@ -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_
|
||||
|
@ -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
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <boost/range/algorithm/equal.hpp>
|
||||
#include <boost/range/detail/safe_bool.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
|
@ -83,11 +83,6 @@ namespace boost
|
||||
detail::range_size<T>
|
||||
{ };
|
||||
|
||||
template< class T >
|
||||
struct range_size<const T > :
|
||||
detail::range_size<T>
|
||||
{ };
|
||||
|
||||
} // namespace boost
|
||||
|
||||
|
||||
|
@ -59,6 +59,8 @@ test-suite range :
|
||||
[ range-test adaptor_test/indexed ]
|
||||
[ range-test adaptor_test/indirected ]
|
||||
[ range-test adaptor_test/map ]
|
||||
[ range-test adaptor_test/ref_unwrapped ]
|
||||
[ range-test adaptor_test/ref_unwrapped_example ]
|
||||
[ range-test adaptor_test/replaced ]
|
||||
[ range-test adaptor_test/replaced_if ]
|
||||
[ range-test adaptor_test/reversed ]
|
||||
@ -219,3 +221,5 @@ test-suite range :
|
||||
[ range-test value_type ]
|
||||
;
|
||||
|
||||
# `quick` target (for CI)
|
||||
alias quick : std_container ;
|
||||
|
@ -51,6 +51,23 @@ namespace boost
|
||||
bool operator()( IntegerT x ) const { return x % 2 != 0; }
|
||||
};
|
||||
|
||||
struct lambda_init
|
||||
{
|
||||
};
|
||||
|
||||
struct lambda
|
||||
{
|
||||
lambda(const lambda_init& init) {}
|
||||
lambda(const lambda& rhs) {}
|
||||
|
||||
template< class T1 >
|
||||
bool operator()(T1) const { return false; }
|
||||
|
||||
private:
|
||||
lambda() {}
|
||||
lambda& operator=(const lambda& rhs) { return *this; }
|
||||
};
|
||||
|
||||
template< class Container, class Pred >
|
||||
void filtered_test_impl( Container& c, Pred pred )
|
||||
{
|
||||
@ -86,32 +103,53 @@ namespace boost
|
||||
test_result2.end() );
|
||||
}
|
||||
|
||||
template< class Rng >
|
||||
void check_copy_assign(Rng r)
|
||||
{
|
||||
Rng r2 = r;
|
||||
r2 = r;
|
||||
}
|
||||
|
||||
template< class Container, class Pred >
|
||||
void filtered_range_copy_assign(Container& c, Pred pred)
|
||||
{
|
||||
using namespace boost::adaptors;
|
||||
check_copy_assign(c | filtered(pred));
|
||||
check_copy_assign(adaptors::filter(c, pred));
|
||||
}
|
||||
|
||||
template< class Container, class Pred, class PredInit >
|
||||
void filtered_test_impl()
|
||||
{
|
||||
using namespace boost::assign;
|
||||
|
||||
Container c;
|
||||
PredInit init;
|
||||
Pred pred(init);
|
||||
|
||||
// test empty container
|
||||
filtered_test_impl(c, Pred());
|
||||
filtered_test_impl(c, pred);
|
||||
|
||||
// test one element
|
||||
c += 1;
|
||||
filtered_test_impl(c, Pred());
|
||||
filtered_test_impl(c, pred);
|
||||
|
||||
// test many elements
|
||||
c += 1,2,2,2,3,4,4,4,4,5,6,7,8,9,9;
|
||||
filtered_test_impl(c, Pred());
|
||||
filtered_test_impl(c, pred);
|
||||
|
||||
// test the range and iterator are copy assignable
|
||||
filtered_range_copy_assign(c, pred);
|
||||
}
|
||||
|
||||
template< class Container >
|
||||
void filtered_test_all_predicates()
|
||||
{
|
||||
filtered_test_impl< Container, always_false_pred >();
|
||||
filtered_test_impl< Container, always_true_pred >();
|
||||
filtered_test_impl< Container, is_odd >();
|
||||
filtered_test_impl< Container, is_even >();
|
||||
filtered_test_impl< Container, always_false_pred, always_false_pred >();
|
||||
filtered_test_impl< Container, always_true_pred, always_true_pred >();
|
||||
filtered_test_impl< Container, is_odd, is_odd >();
|
||||
filtered_test_impl< Container, is_even, is_even >();
|
||||
filtered_test_impl< Container, lambda, lambda_init >();
|
||||
}
|
||||
|
||||
void ticket_10988_single_pass()
|
||||
|
101
test/adaptor_test/ref_unwrapped.cpp
Normal file
101
test/adaptor_test/ref_unwrapped.cpp
Normal 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) && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
||||
|
||||
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
|
47
test/adaptor_test/ref_unwrapped_example.cpp
Normal file
47
test/adaptor_test/ref_unwrapped_example.cpp
Normal 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
|
||||
//->
|
||||
}
|
||||
//]
|
@ -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.
|
||||
|
@ -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()
|
||||
|
@ -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>() );
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 ));
|
||||
|
@ -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 ) ) );
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
Reference in New Issue
Block a user