Merge pull request #19 from ericniebler/develop

Possible fix for iterator_range SFINAE bug
This commit is contained in:
neilgroves
2014-08-10 17:07:10 +01:00
2 changed files with 30 additions and 2 deletions

View File

@ -442,8 +442,8 @@ public:
> base_type; > base_type;
template<class Source> template<class Source>
struct is_compatible_range struct is_compatible_range_
: is_convertible< : is_convertible<
BOOST_DEDUCED_TYPENAME mpl::eval_if< BOOST_DEDUCED_TYPENAME mpl::eval_if<
has_range_iterator<Source>, has_range_iterator<Source>,
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: protected:
typedef iterator_range_detail::iterator_range_impl<IteratorT> impl; typedef iterator_range_detail::iterator_range_impl<IteratorT> impl;

View File

@ -266,6 +266,20 @@ inline void test_advance()
BOOST_CHECK_EQUAL(r3.advance_end(-1).size(), 1u); 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* init_unit_test_suite( int argc, char* argv[] )
{ {
boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" ); boost::unit_test::test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );