diff --git a/include/boost/iterator/is_lvalue_iterator.hpp b/include/boost/iterator/is_lvalue_iterator.hpp index a89b373..9a31322 100755 --- a/include/boost/iterator/is_lvalue_iterator.hpp +++ b/include/boost/iterator/is_lvalue_iterator.hpp @@ -126,7 +126,7 @@ namespace detail {}; template - struct is_writable_lvalue_iterator_impl + struct is_mutable_lvalue_iterator_impl : is_lvalue_iterator_impl< BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type >::template rebind @@ -136,10 +136,10 @@ namespace detail // Define the trait with full mpl lambda capability and various broken // compiler workarounds BOOST_TT_AUX_BOOL_TRAIT_DEF1( - is_readable_lvalue_iterator,T,::boost::detail::is_readable_lvalue_iterator_impl::value) + is_lvalue_iterator,T,::boost::detail::is_readable_lvalue_iterator_impl::value) BOOST_TT_AUX_BOOL_TRAIT_DEF1( - is_writable_lvalue_iterator,T,::boost::detail::is_writable_lvalue_iterator_impl::value) + is_mutable_lvalue_iterator,T,::boost::detail::is_mutable_lvalue_iterator_impl::value) } // namespace boost diff --git a/include/boost/iterator/is_readable_iterator.hpp b/include/boost/iterator/is_readable_iterator.hpp new file mode 100755 index 0000000..40ab89f --- /dev/null +++ b/include/boost/iterator/is_readable_iterator.hpp @@ -0,0 +1,108 @@ +// Copyright David Abrahams 2003. 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) +#ifndef IS_READABLE_ITERATOR_DWA2003112_HPP +# define IS_READABLE_ITERATOR_DWA2003112_HPP + +#include +#include + +// should be the last #include +#include +#include + +namespace boost { + +namespace detail +{ + struct any_conversion_eater + { + template + any_conversion_eater(T const&); + }; + + // Guts of is_readable_iterator. Value is the iterator's value_type + // and the result is computed in the nested rebind template. + template + struct is_readable_iterator_impl + { + static char tester(Value&, int); + static char (& tester(any_conversion_eater, ...) )[2]; + + template + struct rebind + { + static It& x; + + BOOST_STATIC_CONSTANT( + bool + , value = ( + sizeof( + is_readable_iterator_impl::tester(*x, 1) + ) == 1 + ) + ); + }; + }; + +#undef BOOST_READABLE_PRESERVER + + // + // void specializations to handle std input and output iterators + // + template <> + struct is_readable_iterator_impl + { + template + struct rebind : boost::mpl::false_ + {}; + }; + +#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS + template <> + struct is_readable_iterator_impl + { + template + struct rebind : boost::mpl::false_ + {}; + }; + + template <> + struct is_readable_iterator_impl + { + template + struct rebind : boost::mpl::false_ + {}; + }; + + template <> + struct is_readable_iterator_impl + { + template + struct rebind : boost::mpl::false_ + {}; + }; +#endif + + // + // This level of dispatching is required for Borland. We might save + // an instantiation by removing it for others. + // + template + struct is_readable_iterator_impl2 + : is_readable_iterator_impl< + BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits::value_type const + >::template rebind + {}; +} // namespace detail + +// Define the trait with full mpl lambda capability and various broken +// compiler workarounds +BOOST_TT_AUX_BOOL_TRAIT_DEF1( + is_readable_iterator,T,::boost::detail::is_readable_iterator_impl2::value) + +} // namespace boost + +#include + +#endif // IS_READABLE_ITERATOR_DWA2003112_HPP diff --git a/test/is_lvalue_iterator.cpp b/test/is_lvalue_iterator.cpp index df2449b..9c23c9c 100755 --- a/test/is_lvalue_iterator.cpp +++ b/test/is_lvalue_iterator.cpp @@ -56,32 +56,32 @@ BOOST_TT_BROKEN_COMPILER_SPEC(proxy_iterator::proxy) int main() { - BOOST_STATIC_ASSERT(boost::is_readable_lvalue_iterator::value); - BOOST_STATIC_ASSERT(boost::is_readable_lvalue_iterator::value); - BOOST_STATIC_ASSERT(boost::is_readable_lvalue_iterator::iterator>::value); - BOOST_STATIC_ASSERT(boost::is_readable_lvalue_iterator::const_iterator>::value); - BOOST_STATIC_ASSERT(!boost::is_readable_lvalue_iterator > >::value); - BOOST_STATIC_ASSERT(!boost::is_readable_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(!boost::is_readable_lvalue_iterator::value); + BOOST_STATIC_ASSERT(boost::is_lvalue_iterator::value); + BOOST_STATIC_ASSERT(boost::is_lvalue_iterator::value); + BOOST_STATIC_ASSERT(boost::is_lvalue_iterator::iterator>::value); + BOOST_STATIC_ASSERT(boost::is_lvalue_iterator::const_iterator>::value); + BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator > >::value); + BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator >::value); + BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator::value); #ifndef BOOST_NO_LVALUE_RETURN_DETECTION - BOOST_STATIC_ASSERT(!boost::is_readable_lvalue_iterator::value); + BOOST_STATIC_ASSERT(!boost::is_lvalue_iterator::value); #endif // Make sure inaccessible copy constructor doesn't prevent // reference binding - BOOST_STATIC_ASSERT(boost::is_readable_lvalue_iterator::value); + BOOST_STATIC_ASSERT(boost::is_lvalue_iterator::value); - BOOST_STATIC_ASSERT(boost::is_writable_lvalue_iterator::value); - BOOST_STATIC_ASSERT(!boost::is_writable_lvalue_iterator::value); - BOOST_STATIC_ASSERT(boost::is_writable_lvalue_iterator::iterator>::value); - BOOST_STATIC_ASSERT(!boost::is_writable_lvalue_iterator::const_iterator>::value); - BOOST_STATIC_ASSERT(!boost::is_writable_lvalue_iterator > >::value); - BOOST_STATIC_ASSERT(!boost::is_writable_lvalue_iterator >::value); - BOOST_STATIC_ASSERT(!boost::is_writable_lvalue_iterator::value); + BOOST_STATIC_ASSERT(boost::is_mutable_lvalue_iterator::value); + BOOST_STATIC_ASSERT(!boost::is_mutable_lvalue_iterator::value); + BOOST_STATIC_ASSERT(boost::is_mutable_lvalue_iterator::iterator>::value); + BOOST_STATIC_ASSERT(!boost::is_mutable_lvalue_iterator::const_iterator>::value); + BOOST_STATIC_ASSERT(!boost::is_mutable_lvalue_iterator > >::value); + BOOST_STATIC_ASSERT(!boost::is_mutable_lvalue_iterator >::value); + BOOST_STATIC_ASSERT(!boost::is_mutable_lvalue_iterator::value); #ifndef BOOST_NO_LVALUE_RETURN_DETECTION - BOOST_STATIC_ASSERT(!boost::is_writable_lvalue_iterator::value); + BOOST_STATIC_ASSERT(!boost::is_mutable_lvalue_iterator::value); #endif - BOOST_STATIC_ASSERT(!boost::is_writable_lvalue_iterator::value); + BOOST_STATIC_ASSERT(!boost::is_mutable_lvalue_iterator::value); return 0; }