📄 iterator.hpp
字号:
BOOST_TT_AUX_BOOL_TRAIT_DEF1( is_stlport_40_debug_iterator,T,::boost::detail::is_stlport_40_debug_iterator_impl<T>::value)template <class T>struct stlport_40_debug_iterator_traits{ typedef typename T::value_type value_type; typedef typename T::reference reference; typedef typename T::pointer pointer; typedef typename T::difference_type difference_type; typedef typename T::_Iterator_category iterator_category;};# endif // BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF template <class T> struct pointer_iterator_traits;# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATIONtemplate <class T>struct pointer_iterator_traits<T*>{ typedef typename remove_const<T>::type value_type; typedef T* pointer; typedef T& reference; typedef std::random_access_iterator_tag iterator_category; typedef std::ptrdiff_t difference_type;};# else// In case of no template partial specialization, and if T is a// pointer, iterator_traits<T>::value_type can still be computed. For// some basic types, remove_pointer is manually defined in// type_traits/broken_compiler_spec.hpp. For others, do it yourself.template<class P> class please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee;template<class P>struct pointer_value_type : mpl::if_< is_same<P, typename remove_pointer<P>::type> , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee<P> , typename remove_const< typename remove_pointer<P>::type >::type >{};template<class P>struct pointer_reference : mpl::if_< is_same<P, typename remove_pointer<P>::type> , please_invoke_BOOST_TT_BROKEN_COMPILER_SPEC_on_cv_unqualified_pointee<P> , typename remove_pointer<P>::type& >{};template <class T>struct pointer_iterator_traits{ typedef T pointer; typedef std::random_access_iterator_tag iterator_category; typedef std::ptrdiff_t difference_type; typedef typename pointer_value_type<T>::type value_type; typedef typename pointer_reference<T>::type reference;};# endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION// We'll sort iterator types into one of these classifications, from which we// can determine the difference_type, pointer, reference, and value_typetemplate <class Iterator>struct standard_iterator_traits{ typedef typename Iterator::difference_type difference_type; typedef typename Iterator::value_type value_type; typedef typename Iterator::pointer pointer; typedef typename Iterator::reference reference; typedef typename Iterator::iterator_category iterator_category;};template <class Iterator>struct msvc_stdlib_mutable_traits : std::iterator_traits<Iterator>{ typedef typename std::iterator_traits<Iterator>::distance_type difference_type; typedef typename std::iterator_traits<Iterator>::value_type* pointer; typedef typename std::iterator_traits<Iterator>::value_type& reference;};template <class Iterator>struct msvc_stdlib_const_traits : std::iterator_traits<Iterator>{ typedef typename std::iterator_traits<Iterator>::distance_type difference_type; typedef const typename std::iterator_traits<Iterator>::value_type* pointer; typedef const typename std::iterator_traits<Iterator>::value_type& reference;};# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATIONtemplate <class Iterator>struct is_bad_output_iterator : is_base_and_derived< std::iterator<std::output_iterator_tag,void,void,void,void> , Iterator>{};struct bad_output_iterator_traits{ typedef void value_type; typedef void difference_type; typedef std::output_iterator_tag iterator_category; typedef void pointer; typedef void reference;};# endif// If we're looking at an MSVC6 (old Dinkumware) ``standard''// iterator, this will generate an appropriate traits class. template <class Iterator>struct msvc_stdlib_iterator_traits : mpl::if_< is_mutable_iterator<Iterator> , msvc_stdlib_mutable_traits<Iterator> , msvc_stdlib_const_traits<Iterator> >::type{};template <class Iterator>struct non_pointer_iterator_traits : mpl::if_< // if the iterator contains all the right nested types... is_full_iterator_traits<Iterator> // Use a standard iterator_traits implementation , standard_iterator_traits<Iterator># ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF // Check for STLPort 4.0 broken _Iterator_category type , mpl::if_< is_stlport_40_debug_iterator<Iterator> , stlport_40_debug_iterator_traits<Iterator># endif // Otherwise, assume it's a Dinkum iterator , msvc_stdlib_iterator_traits<Iterator># ifdef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF >::type# endif >::type{};template <class Iterator>struct iterator_traits_aux : mpl::if_< is_pointer<Iterator> , pointer_iterator_traits<Iterator> , non_pointer_iterator_traits<Iterator> >::type{};template <class Iterator>struct iterator_traits{ // Explicit forwarding from base class needed to keep MSVC6 happy // under some circumstances. private:# ifdef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION typedef typename mpl::if_< is_bad_output_iterator<Iterator> , bad_output_iterator_traits , iterator_traits_aux<Iterator> >::type base;# else typedef iterator_traits_aux<Iterator> base;# endif public: typedef typename base::value_type value_type; typedef typename base::pointer pointer; typedef typename base::reference reference; typedef typename base::difference_type difference_type; typedef typename base::iterator_category iterator_category;};// This specialization cuts off ETI (Early Template Instantiation) for MSVC.template <> struct iterator_traits<int>{ typedef int value_type; typedef int pointer; typedef int reference; typedef int difference_type; typedef int iterator_category;};}} // namespace boost::detail# endif // workaroundsnamespace boost { namespace detail {namespace iterator_traits_{ template <class Iterator, class Difference> struct distance_select { static Difference execute(Iterator i1, const Iterator i2, ...) { Difference result = 0; while (i1 != i2) { ++i1; ++result; } return result; } static Difference execute(Iterator i1, const Iterator i2, std::random_access_iterator_tag*) { return i2 - i1; } };} // namespace boost::detail::iterator_traits_template <class Iterator>inline typename iterator_traits<Iterator>::difference_typedistance(Iterator first, Iterator last){ typedef typename iterator_traits<Iterator>::difference_type diff_t; typedef typename ::boost::detail::iterator_traits<Iterator>::iterator_category iterator_category; return iterator_traits_::distance_select<Iterator,diff_t>::execute( first, last, (iterator_category*)0);}}}# endif# undef BOOST_BAD_CONTAINER_ITERATOR_CATEGORY_TYPEDEF# undef BOOST_BAD_OUTPUT_ITERATOR_SPECIALIZATION#endif // ITERATOR_DWA122600_HPP_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -