diff --git a/include/boost/iterator/detail/minimum_category.hpp b/include/boost/iterator/detail/minimum_category.hpp index 50fe6f5..d56ab9a 100755 --- a/include/boost/iterator/detail/minimum_category.hpp +++ b/include/boost/iterator/detail/minimum_category.hpp @@ -21,7 +21,13 @@ namespace boost { namespace detail { // // template -struct minimum_category_impl; +struct minimum_category_impl +# if BOOST_WORKAROUND(BOOST_MSVC, == 1200) +{ + typedef void type; +} +# endif +; template struct error_not_related_by_convertibility; @@ -58,15 +64,9 @@ template <> struct minimum_category_impl { template struct apply -# if BOOST_WORKAROUND(BOOST_MSVC, == 1200) - { - typedef void type; - }; -# else : error_not_related_by_convertibility { }; -# endif }; template diff --git a/include/boost/iterator/indirect_iterator.hpp b/include/boost/iterator/indirect_iterator.hpp index d2b7351..91c4283 100644 --- a/include/boost/iterator/indirect_iterator.hpp +++ b/include/boost/iterator/indirect_iterator.hpp @@ -12,11 +12,15 @@ #include #include -#include - -#include +#include +#include +#include #include + +#include +#include + #include #include #include @@ -39,43 +43,6 @@ namespace boost namespace detail { - template - struct iterator_is_mutable - : mpl::not_< - boost::python::detail::is_reference_to_const< - typename iterator_reference::type - > - > - { - }; - - // If the Value parameter is unspecified, we use this metafunction - // to deduce the default type - template - struct default_indirect_value - { - typedef typename mpl::if_< - iterator_is_mutable - , typename iterator_value::type - , typename iterator_value::type const - >::type type; - }; - - // If the Reference parameter is unspecified, we use this metafunction - // to deduce the default type - template - struct default_indirect_reference - { - struct use_value_ref { typedef Value& type; }; - - typedef typename - mpl::apply_if< - is_same - , iterator_reference - , use_value_ref - >::type type; - }; - template struct indirect_base { @@ -85,11 +52,16 @@ namespace boost indirect_iterator , Iter , typename ia_dflt_help< - Value, default_indirect_value + Value, pointee >::type , Category , typename ia_dflt_help< - Reference, default_indirect_reference + Reference + , mpl::apply_if< + is_same + , indirect_reference + , add_reference + > >::type , Difference > type; diff --git a/include/boost/iterator/iterator_concepts.hpp b/include/boost/iterator/iterator_concepts.hpp index e67d371..93e0972 100644 --- a/include/boost/iterator/iterator_concepts.hpp +++ b/include/boost/iterator/iterator_concepts.hpp @@ -346,35 +346,50 @@ namespace detail } // namespace detail - template - class InteroperableConcept - { - public: - typedef typename boost::iterator_traversal::type traversal_category; - typedef typename boost::detail::iterator_traits::difference_type - difference_type; + template + class InteroperableConcept + { + public: + typedef typename boost::detail::pure_traversal_tag< + typename boost::iterator_traversal< + Iterator + >::type + >::type traversal_category; + + typedef typename + boost::detail::iterator_traits::difference_type + difference_type; - typedef typename boost::iterator_traversal::type - const_traversal_category; - typedef typename boost::detail::iterator_traits::difference_type - const_difference_type; + typedef typename boost::detail::pure_traversal_tag< + typename boost::iterator_traversal< + ConstIterator + >::type + >::type const_traversal_category; + + typedef typename + boost::detail::iterator_traits::difference_type + const_difference_type; - void constraints() { - BOOST_STATIC_ASSERT((boost::is_same< difference_type, - const_difference_type>::value)); - BOOST_STATIC_ASSERT((boost::is_same< traversal_category, - const_traversal_category>::value)); - - // ToDo check what the std really requires - - // detail::Operations::constraints(i, ci); + void constraints() + { + BOOST_STATIC_ASSERT( + (boost::is_same< difference_type, const_difference_type>::value) + ); + + BOOST_STATIC_ASSERT( + (boost::is_same< traversal_category, const_traversal_category>::value) + ); - ci = i; + // ToDo check what the std really requires - } - Iterator i; - ConstIterator ci; - }; + // detail::Operations::constraints(i, ci); + + ci = i; + + } + Iterator i; + ConstIterator ci; + }; } // namespace boost_concepts diff --git a/include/boost/pointee.hpp b/include/boost/pointee.hpp new file mode 100755 index 0000000..5c40a0f --- /dev/null +++ b/include/boost/pointee.hpp @@ -0,0 +1,40 @@ +// Copyright David Abrahams 2004. 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 POINTEE_DWA200415_HPP +# define POINTEE_DWA200415_HPP + +// dereferenceable_traits provides access to the value_type and +// reference of a Dereferenceable type. + +# include +# include +# include +# include + +namespace boost { + +namespace detail +{ + template + struct smart_ptr_value + { + typedef typename remove_cv::type type; + }; +} + +template +struct pointee +{ + typedef typename remove_cv

::type stripped; + + typedef typename mpl::apply_if< + detail::is_incrementable + , iterator_value + , detail::smart_ptr_value + >::type type; +}; + +} // namespace boost + +#endif // POINTEE_DWA200415_HPP diff --git a/test/Jamfile b/test/Jamfile index f2607bc..1cd2c81 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -18,7 +18,13 @@ test-suite iterator # compilation problems. [ run is_convertible_fail.cpp ] - [ run zip_iterator_test.cpp ] + [ run zip_iterator_test.cpp + : : : + + # stlport's debug mode generates long symbols which overwhelm + # vc6 + <*>release + ] # These tests should work for just about everything. [ compile is_lvalue_iterator.cpp ] diff --git a/test/indirect_iterator_member_types.cpp b/test/indirect_iterator_member_types.cpp index 6ba2049..55bff61 100644 --- a/test/indirect_iterator_member_types.cpp +++ b/test/indirect_iterator_member_types.cpp @@ -14,26 +14,44 @@ #include #include +#include "static_assert_same.hpp" #include struct zow { }; struct my_ptr { - typedef zow value_type; - typedef const zow& reference; - typedef const zow* pointer; - typedef void difference_type; - typedef boost::no_traversal_tag iterator_category; + typedef zow const element_type; +// typedef const zow& reference; +// typedef const zow* pointer; +// typedef void difference_type; +// typedef boost::no_traversal_tag iterator_category; }; +BOOST_TT_BROKEN_COMPILER_SPEC(my_ptr) +BOOST_TT_BROKEN_COMPILER_SPEC(zow) + +#ifndef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY + +# define STATIC_ASSERT_SAME_POINTER(P1, P2) \ + STATIC_ASSERT_SAME( \ + boost::remove_const::type>::type \ + , boost::remove_const::type>::type \ + ) + +#else + +# define STATIC_ASSERT_SAME_POINTER(P1, P2) STATIC_ASSERT_SAME(P1,P2) + +#endif + int main() { { typedef boost::indirect_iterator Iter; - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); + STATIC_ASSERT_SAME(Iter::value_type, int); + STATIC_ASSERT_SAME(Iter::reference, int&); + STATIC_ASSERT_SAME_POINTER(Iter::pointer, int*); + STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t); BOOST_STATIC_ASSERT((boost::is_convertible::value)); @@ -42,28 +60,34 @@ int main() } { typedef boost::indirect_iterator Iter; - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); + STATIC_ASSERT_SAME(Iter::value_type, int); + STATIC_ASSERT_SAME(Iter::reference, const int&); +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) // Borland drops const all over the place + STATIC_ASSERT_SAME_POINTER(Iter::pointer, const int*); +#endif } { typedef boost::indirect_iterator Iter; - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); + STATIC_ASSERT_SAME(Iter::value_type, int); + STATIC_ASSERT_SAME(Iter::reference, int&); + STATIC_ASSERT_SAME_POINTER(Iter::pointer, int*); } { typedef boost::indirect_iterator Iter; - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); + STATIC_ASSERT_SAME(Iter::value_type, int); + STATIC_ASSERT_SAME(Iter::reference, const int&); +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) // Borland drops const all over the place + STATIC_ASSERT_SAME_POINTER(Iter::pointer, const int*); +#endif } { typedef boost::indirect_iterator Iter; - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); + STATIC_ASSERT_SAME(Iter::value_type, zow); +#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) // Borland drops const all over the place + STATIC_ASSERT_SAME(Iter::reference, const zow&); + STATIC_ASSERT_SAME_POINTER(Iter::pointer, const zow*); +#endif + STATIC_ASSERT_SAME(Iter::difference_type, std::ptrdiff_t); BOOST_STATIC_ASSERT((boost::is_convertible::value)); @@ -72,9 +96,10 @@ int main() } { typedef boost::indirect_iterator Iter; - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); - BOOST_STATIC_ASSERT((boost::is_same::value)); + STATIC_ASSERT_SAME(Iter::value_type, int); + STATIC_ASSERT_SAME(Iter::reference, long&); + STATIC_ASSERT_SAME_POINTER(Iter::pointer, int*); + STATIC_ASSERT_SAME(Iter::difference_type, short); } + return 0; } diff --git a/test/indirect_iterator_test.cpp b/test/indirect_iterator_test.cpp index 05a2db2..56db69b 100644 --- a/test/indirect_iterator_test.cpp +++ b/test/indirect_iterator_test.cpp @@ -26,6 +26,8 @@ #include #include +#include + #include #include #include @@ -139,6 +141,10 @@ void more_indirect_iterator_tests() assert(std::equal(db, de, store.begin())); } +// element_type detector; defaults to true so the test passes when +// has_xxx isn't implemented +BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_element_type, element_type, true) + int main() { @@ -146,6 +152,10 @@ main() dummyT(3), dummyT(4), dummyT(5) }; const int N = sizeof(array)/sizeof(dummyT); +# if BOOST_WORKAROUND(BOOST_MSVC, == 1200) + boost::shared_ptr zz((dummyT*)0); // Why? I don't know, but it suppresses a bad instantiation. +# endif + typedef std::vector > shared_t; shared_t shared; @@ -154,9 +164,8 @@ main() typedef boost::indirect_iterator iter_t; BOOST_STATIC_ASSERT( - boost::detail::has_element_type< - boost::shared_ptr - // std::iterator_traits::value_type + has_element_type< + boost::detail::iterator_traits::value_type >::value ); diff --git a/test/static_assert_same.hpp b/test/static_assert_same.hpp index e463192..0b4b04c 100644 --- a/test/static_assert_same.hpp +++ b/test/static_assert_same.hpp @@ -7,6 +7,7 @@ # define STATIC_ASSERT_SAME_DWA2003530_HPP # include +# include #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION template @@ -32,4 +33,8 @@ struct static_assert_same {}; #endif +#define STATIC_ASSERT_SAME( T1,T2 ) \ + enum { BOOST_JOIN(boost_static_assert_enum_, __LINE__) \ + = static_assert_same::value } + #endif // STATIC_ASSERT_SAME_DWA2003530_HPP diff --git a/test/zip_iterator_test.cpp b/test/zip_iterator_test.cpp index f33dbd9..274f7ac 100755 --- a/test/zip_iterator_test.cpp +++ b/test/zip_iterator_test.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include