📄 _iterator_base.h
字号:
/* * * Copyright (c) 1994 * Hewlett-Packard Company * * Copyright (c) 1996-1998 * Silicon Graphics Computer Systems, Inc. * * Copyright (c) 1997 * Moscow Center for SPARC Technology * * Copyright (c) 1999 * Boris Fomitchev * * This material is provided "as is", with absolutely no warranty expressed * or implied. Any use is at your own risk. * * Permission to use or copy this software for any purpose is hereby granted * without fee, provided the above notices are retained on all copies. * Permission to modify the code and to distribute modified code is granted, * provided the above notices are retained, and a notice that the code was * modified is included with the above copyright notice. * *//* NOTE: This is an internal header file, included by other STL headers. * You should not attempt to use it directly. */#ifndef _STLP_INTERNAL_ITERATOR_BASE_H#define _STLP_INTERNAL_ITERATOR_BASE_H#ifndef _STLP_INTERNAL_CSTDDEF# include <stl/_cstddef.h>#endif//# if defined (_STLP_IMPORT_VENDOR_CSTD) && ! defined (_STLP_VENDOR_GLOBAL_CSTD)//_STLP_BEGIN_NAMESPACE//using namespace _STLP_VENDOR_CSTD;//_STLP_END_NAMESPACE//#endif /* _STLP_IMPORT_VENDOR_CSTD */#if !defined(_STLP_USE_OLD_HP_ITERATOR_QUERIES) && !defined(_STLP_CLASS_PARTIAL_SPECIALIZATION)# ifndef _STLP_TYPE_TRAITS_H# include <stl/type_traits.h># endif#endif_STLP_BEGIN_NAMESPACEstruct input_iterator_tag {};struct output_iterator_tag {};struct forward_iterator_tag : public input_iterator_tag {};struct bidirectional_iterator_tag : public forward_iterator_tag {};struct random_access_iterator_tag : public bidirectional_iterator_tag {};template <class _Category, class _Tp, _STLP_DFL_TMPL_PARAM(_Distance,ptrdiff_t), _STLP_DFL_TMPL_PARAM(_Pointer,_Tp*), _STLP_DFL_TMPL_PARAM(_Reference,_Tp&) >struct iterator { typedef _Category iterator_category; typedef _Tp value_type; typedef _Distance difference_type; typedef _Pointer pointer; typedef _Reference reference;};_STLP_TEMPLATE_NULLstruct iterator<output_iterator_tag, void, void, void, void> { typedef output_iterator_tag iterator_category;#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION typedef void value_type; typedef void difference_type; typedef void pointer; typedef void reference;#endif};#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::iterator_category(_It)# define _STLP_DISTANCE_TYPE(_It, _Tp) _STLP_STD::distance_type(_It)# define _STLP_VALUE_TYPE(_It, _Tp) _STLP_STD::value_type(_It)//Old HP iterator queries do not give information about the iterator//associated reference type so we consider that it is not a real reference.# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type()#else# if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)# define _STLP_VALUE_TYPE(_It, _Tp) (_STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::value_type*)0# define _STLP_DISTANCE_TYPE(_It, _Tp) (_STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::difference_type*)0# if defined (__BORLANDC__) || defined (__SUNPRO_CC) || ( defined (__MWERKS__) && (__MWERKS__ <= 0x2303)) || \ (defined (__sgi) && defined (_COMPILER_VERSION)) || defined (__DMC__)# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::iterator_traits< _Tp >::iterator_category()# else# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::iterator_category()# endif# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) _STLP_STD::_IsRefType< _STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::reference >::_Ret()# else# define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::__iterator_category(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret())# define _STLP_DISTANCE_TYPE(_It, _Tp) _STLP_STD::__distance_type(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret())# define _STLP_VALUE_TYPE(_It, _Tp) _STLP_STD::__value_type(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret())# define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type()# endif#endif#if defined (_STLP_DONT_REDEFINE_STD) && defined (_STLP_WHOLE_NATIVE_STD)/* In this mode we will see both STLport implementation and native * one. To allow some interaction between both implementations through * iterators we have to map std iterator categories to stlport ones. This * way we will be able to initialize STLport containers with native * iterators, the other side won't work except when STLport iterators are * simple pointers. */_STLP_END_NAMESPACE# if defined (_STLP_HAS_INCLUDE_NEXT)# include_next <iterator># else# include _STLP_NATIVE_HEADER(iterator)# endif_STLP_BEGIN_NAMESPACEtemplate <class _IteCat>struct _CategoryMapping{ typedef _IteCat _Tag; };_STLP_TEMPLATE_NULLstruct _CategoryMapping<::std::input_iterator_tag>{ typedef input_iterator_tag _Tag; };_STLP_TEMPLATE_NULLstruct _CategoryMapping<::std::output_iterator_tag>{ typedef output_iterator_tag _Tag; };_STLP_TEMPLATE_NULLstruct _CategoryMapping<::std::forward_iterator_tag>{ typedef forward_iterator_tag _Tag; };_STLP_TEMPLATE_NULLstruct _CategoryMapping<::std::bidirectional_iterator_tag>{ typedef bidirectional_iterator_tag _Tag; };_STLP_TEMPLATE_NULLstruct _CategoryMapping<::std::random_access_iterator_tag>{ typedef random_access_iterator_tag _Tag; };template <class _Iterator>struct iterator_traits { typedef typename _Iterator::iterator_category _OriginalTag; typedef typename _CategoryMapping<_OriginalTag>::_Tag iterator_category;#elsetemplate <class _Iterator>struct iterator_traits { typedef typename _Iterator::iterator_category iterator_category;#endif typedef typename _Iterator::value_type value_type; typedef typename _Iterator::difference_type difference_type; typedef typename _Iterator::pointer pointer; typedef typename _Iterator::reference reference;};#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (__SUNPRO_CC)# define _STLP_DIFFERENCE_TYPE(_Iterator) typename iterator_traits<_Iterator>::difference_type#else# define _STLP_DIFFERENCE_TYPE(_Iterator) ptrdiff_t#endif#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION// fbp : this order keeps gcc happytemplate <class _Tp>struct iterator_traits<const _Tp*> { typedef random_access_iterator_tag iterator_category; typedef _Tp value_type; typedef ptrdiff_t difference_type; typedef const _Tp* pointer; typedef const _Tp& reference;};template <class _Tp>struct iterator_traits<_Tp*> { typedef random_access_iterator_tag iterator_category; typedef _Tp value_type; typedef ptrdiff_t difference_type; typedef _Tp* pointer; typedef _Tp& reference;};# if defined (__BORLANDC__)template <class _Tp>struct iterator_traits<_Tp* const> { typedef random_access_iterator_tag iterator_category; typedef _Tp value_type; typedef ptrdiff_t difference_type; typedef const _Tp* pointer; typedef const _Tp& reference;};# endif#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */_STLP_END_NAMESPACE#include <stl/_ptrs_specialize.h>_STLP_BEGIN_NAMESPACE#ifndef _STLP_USE_OLD_HP_ITERATOR_QUERIES// The overloaded functions iterator_category, distance_type, and// value_type are not part of the C++ standard. (They have been// replaced by struct iterator_traits.) They are included for// backward compatibility with the HP STL.// We introduce internal names for these functions.# ifndef _STLP_CLASS_PARTIAL_SPECIALIZATIONtemplate <class _Tp>inline _STLP_STD::random_access_iterator_tag__iterator_category(const _Tp*, const __true_type&){ return _STLP_STD::random_access_iterator_tag(); }template <class _Iter>inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::iterator_category__iterator_category(const _Iter&, const __false_type&) { typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::iterator_category _Category; return _Category();}template <class _Tp>inline ptrdiff_t*__distance_type(const _Tp*, const __true_type&){ return __STATIC_CAST(ptrdiff_t*, 0); }template <class _Iter>inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::difference_type*__distance_type(const _Iter&, const __false_type&) { typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::difference_type _diff_type; return __STATIC_CAST(_diff_type*,0);}template <class _Tp>inline _Tp*__value_type(const _Tp*, const __true_type&){ return __STATIC_CAST(_Tp*, 0); }template <class _Iter>inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::value_type*__value_type(const _Iter&, const __false_type&) { typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::value_type _value_type; return __STATIC_CAST(_value_type*,0);}# endif#else /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>inline _Category _STLP_CALL iterator_category(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return _Category(); }template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>inline _Tp* _STLP_CALL value_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Tp*, 0); }template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>inline _Distance* _STLP_CALL distance_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Distance*, 0); }template <class _Tp>inline random_access_iterator_tag _STLP_CALL iterator_category(const _Tp*) { return random_access_iterator_tag(); }template <class _Tp>inline _Tp* _STLP_CALL value_type(const _Tp*) { return __STATIC_CAST(_Tp*, 0); }template <class _Tp>inline ptrdiff_t* _STLP_CALL distance_type(const _Tp*) { return __STATIC_CAST(ptrdiff_t*, 0); }#endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */#if !defined (_STLP_NO_ANACHRONISMS)// The base classes input_iterator, output_iterator, forward_iterator,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -