diff --git a/include/boost/iterator/iterator_facade.hpp b/include/boost/iterator/iterator_facade.hpp index 10e8116..bc01b5d 100644 --- a/include/boost/iterator/iterator_facade.hpp +++ b/include/boost/iterator/iterator_facade.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -195,6 +196,43 @@ namespace boost Iterator stored_iterator; }; +# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + template + struct is_non_proxy_reference_impl + { + static Reference r; + + template + static typename mpl::if_< + is_convertible< + R const volatile* + , Value const volatile* + > + , char[1] + , char[2] + >::type& helper(R const&); + + BOOST_STATIC_CONSTANT(bool, value = sizeof(helper(r)) == 1); + }; + + template + struct is_non_proxy_reference + : mpl::bool_< + is_non_proxy_reference_impl::value + > + {}; +# else + template + struct is_non_proxy_reference + : is_convertible< + typename remove_reference::type + const volatile* + , Value const volatile* + > + {}; +# endif + // A metafunction to choose the result type of postfix ++ // // Because the C++98 input iterator requirements say that *r++ has @@ -209,7 +247,7 @@ namespace boost // supports the operator<. Since there are any number of such // operations, we're not going to try to support them. Therefore, // even if r++ returns a proxy, *r++ will only return a proxy if - // CategoryOrTraversal is convertible to std::output_iterator_tag. + // *r also returns a proxy. template struct postfix_increment_result : mpl::apply_if< @@ -227,9 +265,9 @@ namespace boost > > , mpl::if_< - is_convertible - , writable_postfix_increment_proxy + is_non_proxy_reference , postfix_increment_proxy + , writable_postfix_increment_proxy > , mpl::identity > diff --git a/test/iterator_facade.cpp b/test/iterator_facade.cpp index c23707c..b478b9c 100755 --- a/test/iterator_facade.cpp +++ b/test/iterator_facade.cpp @@ -11,12 +11,12 @@ // This is a really, really limited test so far. All we're doing // right now is checking that the postfix++ proxy for single-pass // iterators works properly. -template +template class counter_iterator : public boost::iterator_facade< - counter_iterator + counter_iterator , int const - , CategoryOrTraversal + , boost::single_pass_traversal_tag , Ref > { @@ -63,9 +63,7 @@ int main() boost::readable_iterator_test(counter_iterator(&state), 0); state = 3; boost::readable_iterator_test(counter_iterator(&state), 3); - state = 5; - boost::readable_iterator_test(counter_iterator(&state), 5); - boost::writable_iterator_test(counter_iterator(&state), 9, 7); + boost::writable_iterator_test(counter_iterator(&state), 9, 7); BOOST_ASSERT(state == 7); return 0; }