mirror of
https://github.com/boostorg/range.git
synced 2025-07-30 12:57:28 +02:00
Merge branch 'develop'
This commit is contained in:
@ -12,9 +12,9 @@
|
|||||||
]
|
]
|
||||||
|
|
||||||
* [*Precondition:] The `value_type` of the range is convertible to the argument type of `pred`.
|
* [*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.
|
* [*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)>`
|
* [*Range Return Type:] `boost::filtered_range<decltype(rng)>`
|
||||||
* [*Returned Range Category:] The minimum of the range category of `rng` and __bidirectional_range__
|
* [*Returned Range Category:] The minimum of the range category of `rng` and __bidirectional_range__
|
||||||
|
|
||||||
|
@ -56,23 +56,23 @@ namespace boost
|
|||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class ForwardRange, class Predicate >
|
template< class SinglePassRange, class Predicate >
|
||||||
inline filtered_range<Predicate, ForwardRange>
|
inline filtered_range<Predicate, SinglePassRange>
|
||||||
operator|(ForwardRange& r,
|
operator|(SinglePassRange& r,
|
||||||
const filter_holder<Predicate>& f)
|
const filter_holder<Predicate>& f)
|
||||||
{
|
{
|
||||||
BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
|
BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<SinglePassRange>));
|
||||||
return filtered_range<Predicate, ForwardRange>( f.val, r );
|
return filtered_range<Predicate, SinglePassRange>( f.val, r );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class ForwardRange, class Predicate >
|
template< class SinglePassRange, class Predicate >
|
||||||
inline filtered_range<Predicate, const ForwardRange>
|
inline filtered_range<Predicate, const SinglePassRange>
|
||||||
operator|(const ForwardRange& r,
|
operator|(const SinglePassRange& r,
|
||||||
const filter_holder<Predicate>& f )
|
const filter_holder<Predicate>& f )
|
||||||
{
|
{
|
||||||
BOOST_RANGE_CONCEPT_ASSERT((
|
BOOST_RANGE_CONCEPT_ASSERT((
|
||||||
ForwardRangeConcept<const ForwardRange>));
|
SinglePassRangeConcept<const SinglePassRange>));
|
||||||
return filtered_range<Predicate, const ForwardRange>( f.val, r );
|
return filtered_range<Predicate, const SinglePassRange>( f.val, r );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 'range_detail'
|
} // 'range_detail'
|
||||||
@ -93,23 +93,26 @@ namespace boost
|
|||||||
range_detail::forwarder<range_detail::filter_holder>();
|
range_detail::forwarder<range_detail::filter_holder>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ForwardRange, class Predicate>
|
template<class SinglePassRange, class Predicate>
|
||||||
inline filtered_range<Predicate, ForwardRange>
|
inline filtered_range<Predicate, SinglePassRange>
|
||||||
filter(ForwardRange& rng, Predicate filter_pred)
|
filter(SinglePassRange& 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)
|
|
||||||
{
|
{
|
||||||
BOOST_RANGE_CONCEPT_ASSERT((
|
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'
|
} // 'adaptors'
|
||||||
|
|
||||||
|
@ -603,7 +603,7 @@ namespace boost
|
|||||||
template<
|
template<
|
||||||
class Rng,
|
class Rng,
|
||||||
class Category =
|
class Category =
|
||||||
typename iterator_traversal<
|
typename iterators::pure_iterator_traversal<
|
||||||
typename range_iterator<Rng>::type
|
typename range_iterator<Rng>::type
|
||||||
>::type
|
>::type
|
||||||
>
|
>
|
||||||
|
@ -18,9 +18,10 @@
|
|||||||
#include <boost/range/config.hpp>
|
#include <boost/range/config.hpp>
|
||||||
#include <boost/range/detail/sfinae.hpp>
|
#include <boost/range/detail/sfinae.hpp>
|
||||||
#include <boost/type_traits/is_void.hpp>
|
#include <boost/type_traits/is_void.hpp>
|
||||||
#include <boost/type_traits/detail/ice_or.hpp>
|
#include <boost/mpl/bool.hpp>
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/mpl/if.hpp>
|
||||||
#include <boost/mpl/int.hpp>
|
#include <boost/mpl/int.hpp>
|
||||||
|
#include <boost/mpl/or.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -70,7 +71,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_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_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_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_ = (boost::mpl::or_<boost::mpl::bool_<is_const_char_ptr_>, boost::mpl::bool_<is_const_wchar_t_ptr_> >::value ));
|
||||||
BOOST_STATIC_CONSTANT( bool, is_array_ = boost::is_array<C>::value );
|
BOOST_STATIC_CONSTANT( bool, is_array_ = boost::is_array<C>::value );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -15,20 +15,32 @@
|
|||||||
# pragma once
|
# pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <boost/mpl/and.hpp>
|
||||||
#include <boost/range/config.hpp>
|
#include <boost/range/config.hpp>
|
||||||
#include <boost/range/iterator.hpp>
|
#include <boost/range/iterator.hpp>
|
||||||
|
#include <boost/range/has_range_iterator.hpp>
|
||||||
#include <boost/iterator/iterator_traits.hpp>
|
#include <boost/iterator/iterator_traits.hpp>
|
||||||
#include <boost/type_traits/remove_reference.hpp>
|
#include <boost/type_traits/remove_reference.hpp>
|
||||||
|
|
||||||
namespace boost
|
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 >
|
template< class T >
|
||||||
struct range_difference
|
struct range_difference
|
||||||
: iterator_difference<
|
: range_detail::range_difference<BOOST_DEDUCED_TYPENAME remove_reference<T>::type>
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<
|
|
||||||
BOOST_DEDUCED_TYPENAME remove_reference<T>::type
|
|
||||||
>::type
|
|
||||||
>
|
|
||||||
{ };
|
{ };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,31 +46,29 @@ namespace boost
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template< typename C, typename Enabler=void >
|
template< typename C, typename Enabler=void >
|
||||||
struct range_iterator
|
struct range_iterator
|
||||||
{
|
{
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
|
||||||
|
|
||||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||||
range_detail_vc7_1::range_iterator<C>::type type;
|
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
|
} // namespace boost
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -66,13 +66,13 @@ namespace boost
|
|||||||
template< class ForwardRange >
|
template< class ForwardRange >
|
||||||
static IteratorT adl_begin( ForwardRange& r )
|
static IteratorT adl_begin( ForwardRange& r )
|
||||||
{
|
{
|
||||||
return static_cast<IteratorT>( boost::begin( r ) );
|
return IteratorT( boost::begin( r ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class ForwardRange >
|
template< class ForwardRange >
|
||||||
static IteratorT adl_end( ForwardRange& r )
|
static IteratorT adl_end( ForwardRange& r )
|
||||||
{
|
{
|
||||||
return static_cast<IteratorT>( boost::end( r ) );
|
return IteratorT( boost::end( r ) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,11 +54,20 @@ namespace boost
|
|||||||
inline typename range_size<const SinglePassRange>::type
|
inline typename range_size<const SinglePassRange>::type
|
||||||
size(const SinglePassRange& rng)
|
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)) && \
|
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||||
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
!BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||||
/**/
|
/**/
|
||||||
using namespace range_detail;
|
using namespace range_detail;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return range_calculate_size(rng);
|
return range_calculate_size(rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <boost/range/config.hpp>
|
#include <boost/range/config.hpp>
|
||||||
#include <boost/range/difference_type.hpp>
|
#include <boost/range/difference_type.hpp>
|
||||||
#include <boost/range/concepts.hpp>
|
#include <boost/range/concepts.hpp>
|
||||||
|
#include <boost/range/has_range_iterator.hpp>
|
||||||
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/utility/enable_if.hpp>
|
||||||
#include <boost/type_traits/make_unsigned.hpp>
|
#include <boost/type_traits/make_unsigned.hpp>
|
||||||
@ -51,7 +52,7 @@ namespace boost
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename C, typename Enabler=void>
|
template<typename C, typename Enabler=void>
|
||||||
struct range_size
|
struct range_size_
|
||||||
{
|
{
|
||||||
typedef BOOST_DEDUCED_TYPENAME make_unsigned<
|
typedef BOOST_DEDUCED_TYPENAME make_unsigned<
|
||||||
BOOST_DEDUCED_TYPENAME range_difference<C>::type
|
BOOST_DEDUCED_TYPENAME range_difference<C>::type
|
||||||
@ -59,7 +60,7 @@ namespace boost
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename C>
|
template<typename C>
|
||||||
struct range_size<
|
struct range_size_<
|
||||||
C,
|
C,
|
||||||
BOOST_DEDUCED_TYPENAME ::boost::enable_if<has_size_type<C>, void>::type
|
BOOST_DEDUCED_TYPENAME ::boost::enable_if<has_size_type<C>, void>::type
|
||||||
>
|
>
|
||||||
@ -67,29 +68,25 @@ namespace boost
|
|||||||
typedef BOOST_DEDUCED_TYPENAME C::size_type type;
|
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 >
|
template< class T >
|
||||||
struct range_size :
|
struct range_size :
|
||||||
detail::range_size<T>
|
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 >
|
template< class T >
|
||||||
struct range_size<const T >
|
struct range_size<const T > :
|
||||||
: detail::range_size<T>
|
detail::range_size<T>
|
||||||
{
|
{ };
|
||||||
#if BOOST_RANGE_ENABLE_CONCEPT_ASSERT == 1
|
|
||||||
BOOST_RANGE_CONCEPT_ASSERT((boost::SinglePassRangeConcept<T>));
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
@ -182,8 +182,8 @@ public:
|
|||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) )
|
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) )
|
||||||
sub_range(const sub_range& r)
|
sub_range(const sub_range& r)
|
||||||
: base(impl::adl_begin(static_cast<const base&>(r)),
|
: base(impl::adl_begin(const_cast<base&>(static_cast<const base&>(r))),
|
||||||
impl::adl_end(static_cast<const base&>(r)))
|
impl::adl_end(const_cast<base&>(static_cast<const base&>(r))))
|
||||||
{ }
|
{ }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -40,10 +40,6 @@ test-suite range :
|
|||||||
[ compile-fail compile_fail/adaptor/copied_concept2.cpp ]
|
[ compile-fail compile_fail/adaptor/copied_concept2.cpp ]
|
||||||
[ compile-fail compile_fail/adaptor/copied_concept3.cpp ]
|
[ compile-fail compile_fail/adaptor/copied_concept3.cpp ]
|
||||||
[ compile-fail compile_fail/adaptor/copied_concept4.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_concept.cpp ]
|
||||||
[ compile-fail compile_fail/adaptor/reversed_concept2.cpp ]
|
[ compile-fail compile_fail/adaptor/reversed_concept2.cpp ]
|
||||||
[ compile-fail compile_fail/adaptor/reversed_concept3.cpp ]
|
[ compile-fail compile_fail/adaptor/reversed_concept3.cpp ]
|
||||||
@ -219,6 +215,7 @@ test-suite range :
|
|||||||
[ range-test ticket_5811_indirected_optional ]
|
[ range-test ticket_5811_indirected_optional ]
|
||||||
[ range-test ticket_6715_iterator_range_equality ]
|
[ range-test ticket_6715_iterator_range_equality ]
|
||||||
[ range-test ticket_6944 ]
|
[ range-test ticket_6944 ]
|
||||||
|
[ range-test ticket_10336 ]
|
||||||
[ range-test value_type ]
|
[ range-test value_type ]
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
@ -113,12 +114,35 @@ namespace boost
|
|||||||
filtered_test_impl< Container, is_even >();
|
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()
|
void filtered_test()
|
||||||
{
|
{
|
||||||
filtered_test_all_predicates< std::vector< int > >();
|
filtered_test_all_predicates< std::vector< int > >();
|
||||||
filtered_test_all_predicates< std::list< int > >();
|
filtered_test_all_predicates< std::list< int > >();
|
||||||
filtered_test_all_predicates< std::set< int > >();
|
filtered_test_all_predicates< std::set< int > >();
|
||||||
filtered_test_all_predicates< std::multiset< int > >();
|
filtered_test_all_predicates< std::multiset< int > >();
|
||||||
|
ticket_10988_single_pass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
|
||||||
}
|
|
@ -244,6 +244,22 @@ inline void test_advance()
|
|||||||
BOOST_CHECK_EQUAL(r3.advance_end(-1).size(), 1u);
|
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
|
} // anonymous namespace
|
||||||
} // namespace boost_range_test
|
} // namespace boost_range_test
|
||||||
|
|
||||||
@ -262,6 +278,8 @@ boost::unit_test::test_suite* init_unit_test_suite(int, char*[])
|
|||||||
|
|
||||||
test->add(BOOST_TEST_CASE(&boost_range_test::test_advance));
|
test->add(BOOST_TEST_CASE(&boost_range_test::test_advance));
|
||||||
|
|
||||||
|
test->add(BOOST_TEST_CASE(&boost_range_test::ticket_10514));
|
||||||
|
|
||||||
return test;
|
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