Small changes to support new iterator adaptors in sandbox

[SVN r18212]
This commit is contained in:
Dave Abrahams
2003-04-09 11:57:59 +00:00
parent 124be84389
commit 69c7068028

View File

@ -62,7 +62,7 @@
# include <cstddef> # include <cstddef>
// should be the last #include // should be the last #include
#include "boost/type_traits/detail/bool_trait_def.hpp" # include "boost/type_traits/detail/bool_trait_def.hpp"
// STLPort 4.0 and betas have a bug when debugging is enabled and there is no // STLPort 4.0 and betas have a bug when debugging is enabled and there is no
// partial specialization: instead of an iterator_category typedef, the standard // partial specialization: instead of an iterator_category typedef, the standard
@ -92,14 +92,19 @@ BOOST_MPL_HAS_XXX_TRAIT_DEF(iterator_category)
# if !defined(BOOST_NO_STD_ITERATOR_TRAITS) \ # if !defined(BOOST_NO_STD_ITERATOR_TRAITS) \
&& !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
&& !defined(BOOST_MSVC_STD_ITERATOR) && !defined(BOOST_MSVC_STD_ITERATOR)
// Define a new template so it can be specialized // Define a new template so it can be specialized
template <class Iterator> template <class Iterator>
struct iterator_traits struct iterator_traits
: std::iterator_traits<Iterator> : std::iterator_traits<Iterator>
{}; {};
using std::distance; using std::distance;
# elif !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
&& !defined(BOOST_MSVC_STD_ITERATOR) # else
# if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
&& !defined(BOOST_MSVC_STD_ITERATOR)
// This is the case where everything conforms except BOOST_NO_STD_ITERATOR_TRAITS
// Rogue Wave Standard Library fools itself into thinking partial // Rogue Wave Standard Library fools itself into thinking partial
// specialization is missing on some platforms (e.g. Sun), so fails to // specialization is missing on some platforms (e.g. Sun), so fails to
@ -134,7 +139,7 @@ struct iterator_traits<T const*>
typedef std::random_access_iterator_tag iterator_category; typedef std::random_access_iterator_tag iterator_category;
}; };
# else # else
// is_mutable_iterator -- // is_mutable_iterator --
// //
@ -193,7 +198,7 @@ BOOST_TT_AUX_BOOL_TRAIT_DEF1(
is_full_iterator_traits,T,::boost::detail::is_full_iterator_traits_impl<T>::value) is_full_iterator_traits,T,::boost::detail::is_full_iterator_traits_impl<T>::value)
# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF # ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
BOOST_MPL_HAS_XXX_TRAIT_DEF(_Iterator_category) BOOST_MPL_HAS_XXX_TRAIT_DEF(_Iterator_category)
// is_stlport_40_debug_iterator -- // is_stlport_40_debug_iterator --
@ -225,11 +230,11 @@ struct stlport_40_debug_iterator_traits
typedef typename T::difference_type difference_type; typedef typename T::difference_type difference_type;
typedef typename T::_Iterator_category iterator_category; typedef typename T::_Iterator_category iterator_category;
}; };
# endif // BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF # endif // BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
template <class T> struct pointer_iterator_traits; template <class T> struct pointer_iterator_traits;
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION # ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
template <class T> template <class T>
struct pointer_iterator_traits<T*> struct pointer_iterator_traits<T*>
{ {
@ -239,7 +244,7 @@ struct pointer_iterator_traits<T*>
typedef std::random_access_iterator_tag iterator_category; typedef std::random_access_iterator_tag iterator_category;
typedef std::ptrdiff_t difference_type; typedef std::ptrdiff_t difference_type;
}; };
# else # else
template <class Ptr> template <class Ptr>
struct must_manually_specialize_boost_detail_iterator_traits; struct must_manually_specialize_boost_detail_iterator_traits;
@ -268,7 +273,7 @@ struct ptr_iter_traits
typedef std::random_access_iterator_tag iterator_category; typedef std::random_access_iterator_tag iterator_category;
typedef std::ptrdiff_t difference_type; typedef std::ptrdiff_t difference_type;
}; };
# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION # endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
// We'll sort iterator types into one of these classifications, from which we // We'll sort iterator types into one of these classifications, from which we
// can determine the difference_type, pointer, reference, and value_type // can determine the difference_type, pointer, reference, and value_type
@ -300,7 +305,7 @@ struct msvc_stdlib_const_traits
typedef const value_type& reference; typedef const value_type& reference;
}; };
# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION # ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION
template <class Iterator> template <class Iterator>
struct is_bad_output_iterator struct is_bad_output_iterator
: is_base_and_derived< : is_base_and_derived<
@ -317,7 +322,7 @@ struct bad_output_iterator_traits
typedef void pointer; typedef void pointer;
typedef void reference; typedef void reference;
}; };
# endif # endif
// If we're looking at an MSVC6 (old Dinkumware) ``standard'' // If we're looking at an MSVC6 (old Dinkumware) ``standard''
// iterator, this will generate an appropriate traits class. // iterator, this will generate an appropriate traits class.
@ -337,17 +342,17 @@ struct non_pointer_iterator_traits
is_full_iterator_traits<Iterator> is_full_iterator_traits<Iterator>
// Use a standard iterator_traits implementation // Use a standard iterator_traits implementation
, standard_iterator_traits<Iterator> , standard_iterator_traits<Iterator>
# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF # ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
// Check for STLPort 4.0 broken _Iterator_category type // Check for STLPort 4.0 broken _Iterator_category type
, mpl::if_< , mpl::if_<
is_stlport_40_debug_iterator<Iterator> is_stlport_40_debug_iterator<Iterator>
, stlport_40_debug_iterator_traits<Iterator> , stlport_40_debug_iterator_traits<Iterator>
# endif # endif
// Otherwise, assume it's a Dinkum iterator // Otherwise, assume it's a Dinkum iterator
, msvc_stdlib_iterator_traits<Iterator> , msvc_stdlib_iterator_traits<Iterator>
# ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF # ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF
>::type >::type
# endif # endif
>::type >::type
{ {
}; };
@ -368,16 +373,16 @@ struct iterator_traits
// Explicit forwarding from base class needed to keep MSVC6 happy // Explicit forwarding from base class needed to keep MSVC6 happy
// under some circumstances. // under some circumstances.
private: private:
# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION # ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION
typedef typedef
typename mpl::if_< typename mpl::if_<
is_bad_output_iterator<Iterator> is_bad_output_iterator<Iterator>
, bad_output_iterator_traits , bad_output_iterator_traits
, iterator_traits_aux<Iterator> , iterator_traits_aux<Iterator>
>::type base; >::type base;
# else # else
typedef iterator_traits_aux<Iterator> base; typedef iterator_traits_aux<Iterator> base;
# endif # endif
public: public:
typedef typename base::value_type value_type; typedef typename base::value_type value_type;
typedef typename base::pointer pointer; typedef typename base::pointer pointer;
@ -389,6 +394,8 @@ struct iterator_traits
// This specialization cuts off ETI (Early Template Instantiation) for MSVC. // This specialization cuts off ETI (Early Template Instantiation) for MSVC.
template <> struct iterator_traits<int>{}; template <> struct iterator_traits<int>{};
# endif
namespace iterator_traits_ namespace iterator_traits_
{ {
template <class Iterator, class Difference> template <class Iterator, class Difference>