forked from boostorg/range
Merge branch 'develop'
Conflicts: include/boost/range/detail/any_iterator.hpp test/iterator_range.cpp
This commit is contained in:
@ -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
|
||||
|
@ -114,7 +114,8 @@ namespace boost
|
||||
};
|
||||
} // namespace range_detail
|
||||
|
||||
namespace iterators {
|
||||
namespace iterators
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
// Rationale:
|
||||
|
@ -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 >
|
||||
@ -117,6 +115,9 @@ 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
|
||||
|
@ -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
|
||||
>
|
||||
{
|
||||
};
|
||||
|
@ -442,8 +442,8 @@ public:
|
||||
> base_type;
|
||||
|
||||
template<class Source>
|
||||
struct is_compatible_range
|
||||
: is_convertible<
|
||||
struct is_compatible_range_
|
||||
: is_convertible<
|
||||
BOOST_DEDUCED_TYPENAME mpl::eval_if<
|
||||
has_range_iterator<Source>,
|
||||
range_iterator<Source>,
|
||||
@ -454,6 +454,20 @@ public:
|
||||
{
|
||||
};
|
||||
|
||||
template<class Source>
|
||||
struct is_compatible_range
|
||||
: mpl::and_<
|
||||
mpl::not_<
|
||||
is_convertible<
|
||||
Source,
|
||||
BOOST_DEDUCED_TYPENAME base_type::iterator
|
||||
>
|
||||
>,
|
||||
is_compatible_range_<Source>
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
protected:
|
||||
typedef iterator_range_detail::iterator_range_impl<IteratorT> impl;
|
||||
|
||||
|
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>"
|
||||
]
|
||||
}
|
@ -266,21 +266,18 @@ inline void test_advance()
|
||||
BOOST_CHECK_EQUAL(r3.advance_end(-1).size(), 1u);
|
||||
}
|
||||
|
||||
boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
struct ptr_iterator
|
||||
: boost::iterator_adaptor<ptr_iterator, int *>
|
||||
{
|
||||
boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
|
||||
ptr_iterator() {}
|
||||
ptr_iterator(int *p) : boost::iterator_adaptor<ptr_iterator, int *>(p) {}
|
||||
private:
|
||||
typedef void iterator; // To throw off the SFINAE mechanism in iterator_range
|
||||
};
|
||||
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range));
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::less>));
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::less_or_equal>));
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::greater>));
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::greater_or_equal>));
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::equal_to>));
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::not_equal_to>));
|
||||
test->add(BOOST_TEST_CASE(&iterator_range_test_detail::check_make_iterator_range_n));
|
||||
test->add(BOOST_TEST_CASE(&test_advance));
|
||||
|
||||
return test;
|
||||
void test_sfinae()
|
||||
{
|
||||
boost::iterator_range<ptr_iterator> r(ptr_iterator(0), ptr_iterator(0));
|
||||
}
|
||||
|
||||
//
|
||||
@ -313,3 +310,21 @@ void check_reference_type()
|
||||
test_iter_range<veci_type>(a_vec);
|
||||
test_iter_range<veci_type const>(a_vec);
|
||||
}
|
||||
|
||||
boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] )
|
||||
{
|
||||
boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
|
||||
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range));
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::less>));
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::less_or_equal>));
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::greater>));
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::greater_or_equal>));
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::equal_to>));
|
||||
test->add(BOOST_TEST_CASE(&check_iterator_range_operator<iterator_range_test_detail::not_equal_to>));
|
||||
test->add(BOOST_TEST_CASE(&iterator_range_test_detail::check_make_iterator_range_n));
|
||||
test->add(BOOST_TEST_CASE(&test_advance));
|
||||
|
||||
return test;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user