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]
This commit is contained in:
Dave Abrahams
2003-08-28 16:52:02 +00:00
parent f325582c40
commit bb7ac6bd84
10 changed files with 39 additions and 105 deletions

View File

@ -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<class To>
struct is_convertible<use_default,To>
: mpl::false_ {};
# endif
namespace detail
{
//
// enable if for use in operator implementation.
//

View File

@ -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 ]
;

View File

@ -149,7 +149,6 @@ main()
test = static_assert_same<traversal_category, boost::random_access_traversal_tag>::value;
(void)test;
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
boost::function_requires<
boost_concepts::WritableLvalueIteratorConcept<int*> >();
boost::function_requires<
@ -159,7 +158,6 @@ main()
boost_concepts::ReadableLvalueIteratorConcept<const int*> >();
boost::function_requires<
boost_concepts::RandomAccessTraversalConcept<const int*> >();
#endif
boost::function_requires<
boost_concepts::WritableLvalueIteratorConcept<new_iterator> >();

View File

@ -7,11 +7,13 @@
#include <boost/iterator/filter_iterator.hpp>
#include <boost/iterator/reverse_iterator.hpp>
#include <boost/iterator/new_iterator_tests.hpp>
#include <boost/type_traits/broken_compiler_spec.hpp>
#include <deque>
#include <iostream>
using boost::dummyT;
BOOST_TT_BROKEN_COMPILER_SPEC(boost::dummyT)
struct one_or_four
{
@ -21,14 +23,6 @@ struct one_or_four
}
};
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
namespace boost { namespace detail
{
template<> struct iterator_traits<dummyT*>
: ptr_iter_traits<dummyT> {};
}}
#endif
template <class T> struct undefined;
// Test filter iterator

View File

@ -26,6 +26,8 @@
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
#include <boost/type_traits/broken_compiler_spec.hpp>
#include <vector>
#include <stdlib.h>
#include <set>
@ -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 <deque>
# ifdef NO_MUTABLE_CONST_STD_DEQUE_ITERATOR_INTEROPERABILITY
# define NO_MUTABLE_CONST_RA_ITERATOR_INTEROPERABILITY
# endif
#else
# define RA_CONTAINER std::vector
# include <vector>
#endif
struct my_iterator_tag : public std::random_access_iterator_tag { };
using boost::dummyT;
BOOST_TT_BROKEN_COMPILER_SPEC(boost::dummyT)
BOOST_TT_BROKEN_COMPILER_SPEC(boost::shared_ptr<boost::dummyT>)
typedef RA_CONTAINER<int> storage;
typedef RA_CONTAINER<int*> pointer_ra_container;
typedef std::vector<int> storage;
typedef std::vector<int*> pointer_ra_container;
typedef std::set<storage::iterator> iterator_set;
template <class Container>
@ -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<int*>
: ptr_iter_traits<int> {};
template<> struct iterator_traits<dummyT*>
: ptr_iter_traits<dummyT> {};
template<> struct iterator_traits<dummyT*const>
: ptr_iter_traits<dummyT> {};
template<> struct iterator_traits<dummyT const*>
: ptr_iter_traits<dummyT, dummyT const> {};
template<> struct iterator_traits<dummyT**>
: ptr_iter_traits<dummyT*> {};
template<> struct iterator_traits<dummyT*const*>
: ptr_iter_traits<dummyT*const> {};
template<> struct iterator_traits<dummyT const*const*>
: ptr_iter_traits<dummyT const*, dummyT const*const> {};
}}
#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<boost::shared_ptr<dummyT> > shared_t;
typedef std::vector<boost::shared_ptr<dummyT> > shared_t;
shared_t shared;
// Concept checks

View File

@ -4,17 +4,6 @@
#include <boost/cstdlib.hpp>
#include <list>
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
namespace boost { namespace detail
{
template<> struct iterator_traits<int*>
: ptr_iter_traits<int> {};
template<> struct iterator_traits<int const*>
: ptr_iter_traits<int, int const> {};
}}
#endif
int main()
{
{

View File

@ -16,6 +16,8 @@
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/pending/iterator_tests.hpp>
# include <boost/type_traits/broken_compiler_spec.hpp>
#include <stdlib.h>
#include <vector>
#include <deque>
@ -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<int,int> intpair;
BOOST_TT_BROKEN_COMPILER_SPEC(intpair)
BOOST_TT_BROKEN_COMPILER_SPEC(dummyT)
#endif
struct mult_functor {
typedef int result_type;

View File

@ -11,18 +11,7 @@
using boost::dummyT;
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
namespace boost
{
namespace detail
{
template<> struct iterator_traits<dummyT*>
: ptr_iter_traits<dummyT> {};
template<> struct iterator_traits<dummyT const*>
: ptr_iter_traits<dummyT const> {};
}
}
#endif
BOOST_TT_BROKEN_COMPILER_SPEC(boost::dummyT)
// Test reverse iterator
int main()

View File

@ -24,21 +24,14 @@
#include <boost/concept_check.hpp>
#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
typedef std::pair<int,int> intpair;
BOOST_TT_BROKEN_COMPILER_SPEC(intpair)
#endif
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
namespace boost { namespace detail
{
template<> struct iterator_traits<int*>
: ptr_iter_traits<int> {};
template<> struct iterator_traits<std::pair<int, int>*>
: ptr_iter_traits<std::pair<int, int> > {};
template<> struct iterator_traits<int const*>
: ptr_iter_traits<int, int const> {};
template<> struct iterator_traits<std::pair<int, int> const*>
: ptr_iter_traits<std::pair<int, int>, std::pair<int, int> const> {};
template<> struct function_object_result<int (*)(int)>
{
typedef int type;

View File

@ -6,15 +6,12 @@
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/static_assert.hpp>
#include "static_assert_same.hpp"
#include <boost/type_traits/broken_compiler_spec.hpp>
struct X { int a; };
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
namespace boost { namespace detail {
template<> struct iterator_traits<X*>
: ptr_iter_traits<X> {};
}}
#endif
BOOST_TT_BROKEN_COMPILER_SPEC(X)
struct Xiter : boost::iterator_adaptor<Xiter,X*>
{