forked from boostorg/range
Compare commits
60 Commits
boost-1.56
...
fix-boost-
Author | SHA1 | Date | |
---|---|---|---|
9e5680b590 | |||
e48b9c38e7 | |||
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 | |||
c6c4a8f3c1 | |||
3d5f3611ba | |||
8c1180f7f2 | |||
8ea11f9281 | |||
811b27141a | |||
a53bd134b2 | |||
0b28fd043f | |||
474c62ab16 | |||
de206a64db | |||
435ca994bf | |||
4a80ccd50d | |||
6f11252633 | |||
688d1bc418 | |||
dcbe4f9365 | |||
e362bb1855 | |||
4f3bdbe4d3 | |||
8bb3a85f68 | |||
0e9a9e613b | |||
18e5bfd037 | |||
51b8115fc1 | |||
4617c43b5e | |||
a58e59ec67 | |||
470a28ecb6 | |||
1e509e6749 | |||
7d13f63d5d | |||
d6bce30c4f | |||
dc0a6b6340 | |||
7fb879a283 | |||
4716c1efec | |||
9d8034d541 | |||
48dfb68045 | |||
1617a513d2 |
@ -28,3 +28,8 @@ boostbook quickbook
|
||||
<format>pdf:<xsl:param>img.src.path=$(images_location)/
|
||||
;
|
||||
|
||||
###############################################################################
|
||||
alias boostdoc ;
|
||||
explicit boostdoc ;
|
||||
alias boostrelease : quickbook ;
|
||||
explicit boostrelease ;
|
||||
|
@ -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]
|
||||
|
@ -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__
|
||||
|
||||
|
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:]
|
||||
|
@ -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
|
||||
|
@ -73,6 +73,10 @@ namespace boost
|
||||
void drop_front();
|
||||
void drop_front(difference_type n);
|
||||
bool empty() const;
|
||||
|
||||
iterator_range& advance_begin(difference_type n);
|
||||
iterator_range& advance_end(difference_type n);
|
||||
|
||||
// for Bidirectional:
|
||||
value_type& back() const;
|
||||
void drop_back();
|
||||
@ -263,6 +267,9 @@ namespace boost
|
||||
reference front();
|
||||
const_reference front() const;
|
||||
|
||||
sub_range& advance_begin(difference_type n);
|
||||
sub_range& advance_end(difference_type n);
|
||||
|
||||
// If traversal >= bidirectional:
|
||||
reference back();
|
||||
const_reference back();
|
||||
|
@ -15,6 +15,9 @@ been noted that some calling code was relying on member functions such as
|
||||
`size()` being present despite the underlying iterators not being random-access
|
||||
due to `iterator_reference<Iter>::type` not being a reference. The suggested
|
||||
refactoring is to use `boost::size(rng)`.
|
||||
# The undocumented __iterator_range__ `pop_front()` has been deprecated and is
|
||||
replaced by `drop_front(). Similarly `pop_back()` has been replaced by
|
||||
`drop_back()`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
@ -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'
|
||||
|
||||
|
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 <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
|
@ -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
|
||||
>
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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* )
|
||||
{
|
||||
|
@ -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:
|
||||
|
@ -114,6 +114,8 @@ namespace boost
|
||||
};
|
||||
} // namespace range_detail
|
||||
|
||||
namespace iterators
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
// Rationale:
|
||||
@ -246,6 +248,7 @@ namespace boost
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
namespace range_detail
|
||||
|
@ -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>
|
||||
|
@ -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 );
|
||||
|
@ -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
|
||||
|
@ -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 );
|
||||
|
||||
};
|
||||
|
@ -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
|
||||
>
|
||||
{
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
{ };
|
||||
}
|
||||
|
||||
|
@ -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_
|
||||
|
@ -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
|
||||
|
@ -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 ) );
|
||||
}
|
||||
};
|
||||
|
||||
@ -266,6 +266,9 @@ public:
|
||||
BOOST_ASSERT(n >= difference_type());
|
||||
std::advance(this->m_Begin, n);
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
void pop_front() { drop_front(); }
|
||||
|
||||
protected:
|
||||
template<class Iterator>
|
||||
@ -331,6 +334,9 @@ public:
|
||||
BOOST_ASSERT(n >= difference_type());
|
||||
std::advance(this->m_End, -n);
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
void pop_back() { drop_back(); }
|
||||
};
|
||||
|
||||
template<class IteratorT>
|
||||
@ -436,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>,
|
||||
@ -448,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;
|
||||
|
||||
@ -528,6 +548,20 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator_range& advance_begin(
|
||||
BOOST_DEDUCED_TYPENAME base_type::difference_type n)
|
||||
{
|
||||
std::advance(this->m_Begin, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator_range& advance_end(
|
||||
BOOST_DEDUCED_TYPENAME base_type::difference_type n)
|
||||
{
|
||||
std::advance(this->m_End, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
//
|
||||
// Allow subclasses an easy way to access the
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
@ -261,6 +261,20 @@ public:
|
||||
iterator_range_::operator=( static_cast<const iterator_range_&>(r) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
sub_range& advance_begin(
|
||||
BOOST_DEDUCED_TYPENAME base::difference_type n)
|
||||
{
|
||||
std::advance(this->m_Begin, n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
sub_range& advance_end(
|
||||
BOOST_DEDUCED_TYPENAME base::difference_type n)
|
||||
{
|
||||
std::advance(this->m_End, n);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace 'boost'
|
||||
|
16
meta/libraries.json
Normal file
16
meta/libraries.json
Normal 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>"
|
||||
]
|
||||
}
|
@ -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 ]
|
||||
;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@ -113,12 +114,35 @@ namespace boost
|
||||
filtered_test_impl< Container, is_even >();
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
filtered_test_all_predicates< std::vector< int > >();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
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)
|
||||
|
||||
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.
|
||||
|
@ -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();
|
||||
}
|
@ -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();
|
||||
}
|
@ -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();
|
||||
}
|
@ -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();
|
||||
}
|
@ -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 ));
|
||||
|
@ -249,6 +249,37 @@ inline void check_iterator_range_operator()
|
||||
Pred());
|
||||
}
|
||||
|
||||
inline void test_advance()
|
||||
{
|
||||
std::vector<int> l;
|
||||
l.push_back(1);
|
||||
l.push_back(2);
|
||||
typedef boost::iterator_range<std::vector<int>::iterator> rng_t;
|
||||
|
||||
rng_t r1(l.begin(), l.end());
|
||||
BOOST_CHECK(r1.advance_begin(1).advance_end(-1).empty());
|
||||
|
||||
rng_t r2(l.begin(), l.end());
|
||||
BOOST_CHECK_EQUAL(r2.advance_begin(1).size(), 1u);
|
||||
|
||||
rng_t r3(l.begin(), l.end());
|
||||
BOOST_CHECK_EQUAL(r3.advance_end(-1).size(), 1u);
|
||||
}
|
||||
|
||||
struct ptr_iterator
|
||||
: boost::iterator_adaptor<ptr_iterator, int *>
|
||||
{
|
||||
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
|
||||
};
|
||||
|
||||
void test_sfinae()
|
||||
{
|
||||
boost::iterator_range<ptr_iterator> r(ptr_iterator(0), ptr_iterator(0));
|
||||
}
|
||||
|
||||
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" );
|
||||
@ -261,6 +292,7 @@ boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -228,6 +228,38 @@ void const_propagation_const_collection(void)
|
||||
check_constant_type(crng.back());
|
||||
}
|
||||
|
||||
inline void test_advance()
|
||||
{
|
||||
std::vector<int> l;
|
||||
l.push_back(1);
|
||||
l.push_back(2);
|
||||
typedef boost::sub_range<std::vector<int> > rng_t;
|
||||
rng_t r1(l.begin(), l.end());
|
||||
BOOST_CHECK(r1.advance_begin(1).advance_end(-1).empty());
|
||||
|
||||
rng_t r2(l.begin(), l.end());
|
||||
BOOST_CHECK_EQUAL(r2.advance_begin(1).size(), 1u);
|
||||
|
||||
rng_t r3(l.begin(), l.end());
|
||||
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
|
||||
|
||||
@ -244,6 +276,10 @@ boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
|
||||
test->add(BOOST_TEST_CASE(
|
||||
&boost_range_test::const_propagation_mutable_collection));
|
||||
|
||||
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
43
test/ticket_10336.cpp
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user