forked from boostorg/range
avoid SFINAE problem in iterator_range constructor
This commit is contained in:
@ -442,7 +442,7 @@ public:
|
||||
> base_type;
|
||||
|
||||
template<class Source>
|
||||
struct is_compatible_range
|
||||
struct is_compatible_range_
|
||||
: is_convertible<
|
||||
BOOST_DEDUCED_TYPENAME mpl::eval_if<
|
||||
has_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;
|
||||
|
||||
|
@ -266,6 +266,20 @@ inline void test_advance()
|
||||
BOOST_CHECK_EQUAL(r3.advance_end(-1).size(), 1u);
|
||||
}
|
||||
|
||||
struct ptr_iterator
|
||||
: boost::iterator_adaptor<ptr_iterator, int *>
|
||||
{
|
||||
ptr_iterator() = default;
|
||||
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" );
|
||||
|
Reference in New Issue
Block a user