From bb7ac6bd84bfe62a5c8555979af028aa87babeb6 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 28 Aug 2003 16:52:02 +0000 Subject: [PATCH] Moved to much cleaner system of using BOOST_TT_BROKEN_COMPILER_SPEC for handling vc6/7 deficiencies with iterator_traits. Fixed a bug in iterator_facade which was causing incomplete types to be passed through is_convertible. Reinstated libs/utility/iterator_traits_test.cpp [SVN r19840] --- include/boost/iterator/iterator_facade.hpp | 10 +++- test/Jamfile | 1 + test/concept_tests.cpp | 2 - test/filter_iterator_test.cpp | 12 ++--- test/indirect_iterator_test.cpp | 59 +++------------------- test/iterator_adaptor_cc.cpp | 11 ---- test/iterator_adaptor_test.cpp | 8 +++ test/reverse_iterator_test.cpp | 15 +----- test/transform_iterator_test.cpp | 17 ++----- test/unit_tests.cpp | 9 ++-- 10 files changed, 39 insertions(+), 105 deletions(-) diff --git a/include/boost/iterator/iterator_facade.hpp b/include/boost/iterator/iterator_facade.hpp index 9ab70ad..3bdb040 100644 --- a/include/boost/iterator/iterator_facade.hpp +++ b/include/boost/iterator/iterator_facade.hpp @@ -37,9 +37,17 @@ namespace boost // explicitly in order to specify that the default should be used. struct use_default; +# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + // the incompleteness of use_default causes massive problems for + // is_convertible (naturally). This workaround is fortunately not + // needed for vc6/vc7. + template + struct is_convertible + : mpl::false_ {}; +# endif + namespace detail { - // // enable if for use in operator implementation. // diff --git a/test/Jamfile b/test/Jamfile index a4672aa..46ff34e 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -39,5 +39,6 @@ test-suite iterator [ run ../../utility/projection_iterator_example.cpp ] [ run ../../utility/reverse_iterator_example.cpp ] [ run ../../utility/transform_iterator_example.cpp ] + [ run ../../utility/iterator_traits_test.cpp ] ; diff --git a/test/concept_tests.cpp b/test/concept_tests.cpp index 64d2c05..5370f76 100644 --- a/test/concept_tests.cpp +++ b/test/concept_tests.cpp @@ -149,7 +149,6 @@ main() test = static_assert_same::value; (void)test; -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) boost::function_requires< boost_concepts::WritableLvalueIteratorConcept >(); boost::function_requires< @@ -159,7 +158,6 @@ main() boost_concepts::ReadableLvalueIteratorConcept >(); boost::function_requires< boost_concepts::RandomAccessTraversalConcept >(); -#endif boost::function_requires< boost_concepts::WritableLvalueIteratorConcept >(); diff --git a/test/filter_iterator_test.cpp b/test/filter_iterator_test.cpp index 16cd894..a00af95 100644 --- a/test/filter_iterator_test.cpp +++ b/test/filter_iterator_test.cpp @@ -7,12 +7,14 @@ #include #include #include +#include #include #include using boost::dummyT; - +BOOST_TT_BROKEN_COMPILER_SPEC(boost::dummyT) + struct one_or_four { bool operator()(dummyT x) const @@ -21,14 +23,6 @@ struct one_or_four } }; -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -namespace boost { namespace detail -{ - template<> struct iterator_traits - : ptr_iter_traits {}; -}} -#endif - template struct undefined; // Test filter iterator diff --git a/test/indirect_iterator_test.cpp b/test/indirect_iterator_test.cpp index 43fa4ae..3f28948 100644 --- a/test/indirect_iterator_test.cpp +++ b/test/indirect_iterator_test.cpp @@ -26,6 +26,8 @@ #include #include +#include +#include #include #include @@ -36,35 +38,19 @@ // std container random-access iterators don't support mutable/const // interoperability (but may support const/mutable interop). -# define NO_MUTABLE_CONST_STD_DEQUE_ITERATOR_INTEROPERABILITY # define NO_MUTABLE_CONST_STD_SET_ITERATOR_INTEROPERABILITY #endif -#if defined(BOOST_MSVC_STD_ITERATOR) \ -|| defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - -// No working iterator_traits implementation, so we must use deque -# define RA_CONTAINER std::deque -# include - -# ifdef NO_MUTABLE_CONST_STD_DEQUE_ITERATOR_INTEROPERABILITY -# define NO_MUTABLE_CONST_RA_ITERATOR_INTEROPERABILITY -# endif - -#else - -# define RA_CONTAINER std::vector -# include - -#endif struct my_iterator_tag : public std::random_access_iterator_tag { }; using boost::dummyT; - -typedef RA_CONTAINER storage; -typedef RA_CONTAINER pointer_ra_container; +BOOST_TT_BROKEN_COMPILER_SPEC(boost::dummyT) +BOOST_TT_BROKEN_COMPILER_SPEC(boost::shared_ptr) + +typedef std::vector storage; +typedef std::vector pointer_ra_container; typedef std::set iterator_set; template @@ -78,36 +64,8 @@ struct indirect_iterator_pair_generator > const_iterator; }; -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -namespace boost { namespace detail -{ - template<> struct iterator_traits - : ptr_iter_traits {}; - - template<> struct iterator_traits - : ptr_iter_traits {}; - - template<> struct iterator_traits - : ptr_iter_traits {}; - - template<> struct iterator_traits - : ptr_iter_traits {}; - - template<> struct iterator_traits - : ptr_iter_traits {}; - - template<> struct iterator_traits - : ptr_iter_traits {}; - - template<> struct iterator_traits - : ptr_iter_traits {}; -}} -#endif - - void more_indirect_iterator_tests() { -# if 0 storage store(1000); std::generate(store.begin(), store.end(), rand); @@ -177,7 +135,6 @@ void more_indirect_iterator_tests() boost::bidirectional_iterator_test(boost::next(sb), store[1], store[2]); assert(std::equal(db, de, store.begin())); -#endif } int @@ -187,7 +144,7 @@ main() dummyT(3), dummyT(4), dummyT(5) }; const int N = sizeof(array)/sizeof(dummyT); - typedef RA_CONTAINER > shared_t; + typedef std::vector > shared_t; shared_t shared; // Concept checks diff --git a/test/iterator_adaptor_cc.cpp b/test/iterator_adaptor_cc.cpp index e08eabd..ba7e79b 100644 --- a/test/iterator_adaptor_cc.cpp +++ b/test/iterator_adaptor_cc.cpp @@ -4,17 +4,6 @@ #include #include -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -namespace boost { namespace detail -{ - template<> struct iterator_traits - : ptr_iter_traits {}; - - template<> struct iterator_traits - : ptr_iter_traits {}; -}} -#endif - int main() { { diff --git a/test/iterator_adaptor_test.cpp b/test/iterator_adaptor_test.cpp index 5c471d7..f59fc6e 100644 --- a/test/iterator_adaptor_test.cpp +++ b/test/iterator_adaptor_test.cpp @@ -16,6 +16,8 @@ #include #include +# include + #include #include #include @@ -28,6 +30,12 @@ struct my_iterator_tag : public std::random_access_iterator_tag { }; using boost::dummyT; +#if BOOST_WORKAROUND(BOOST_MSVC, == 1300) +typedef std::pair intpair; +BOOST_TT_BROKEN_COMPILER_SPEC(intpair) +BOOST_TT_BROKEN_COMPILER_SPEC(dummyT) +#endif + struct mult_functor { typedef int result_type; diff --git a/test/reverse_iterator_test.cpp b/test/reverse_iterator_test.cpp index 0137d97..cb069cd 100644 --- a/test/reverse_iterator_test.cpp +++ b/test/reverse_iterator_test.cpp @@ -11,19 +11,8 @@ using boost::dummyT; -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -namespace boost -{ - namespace detail - { - template<> struct iterator_traits - : ptr_iter_traits {}; - template<> struct iterator_traits - : ptr_iter_traits {}; - } -} -#endif - +BOOST_TT_BROKEN_COMPILER_SPEC(boost::dummyT) + // Test reverse iterator int main() { diff --git a/test/transform_iterator_test.cpp b/test/transform_iterator_test.cpp index 8eb5121..fcbb3d9 100644 --- a/test/transform_iterator_test.cpp +++ b/test/transform_iterator_test.cpp @@ -24,21 +24,14 @@ #include +#if BOOST_WORKAROUND(BOOST_MSVC, == 1300) +typedef std::pair intpair; +BOOST_TT_BROKEN_COMPILER_SPEC(intpair) +#endif + #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION namespace boost { namespace detail { - template<> struct iterator_traits - : ptr_iter_traits {}; - - template<> struct iterator_traits*> - : ptr_iter_traits > {}; - - template<> struct iterator_traits - : ptr_iter_traits {}; - - template<> struct iterator_traits const*> - : ptr_iter_traits, std::pair const> {}; - template<> struct function_object_result { typedef int type; diff --git a/test/unit_tests.cpp b/test/unit_tests.cpp index 622d9a7..ed6c279 100644 --- a/test/unit_tests.cpp +++ b/test/unit_tests.cpp @@ -6,15 +6,12 @@ #include #include #include "static_assert_same.hpp" +#include + struct X { int a; }; -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -namespace boost { namespace detail { -template<> struct iterator_traits - : ptr_iter_traits {}; -}} -#endif +BOOST_TT_BROKEN_COMPILER_SPEC(X) struct Xiter : boost::iterator_adaptor {