📄 iterator_helper.hpp
字号:
#ifdef STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM5_SUPPORT
# undef STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM5_SUPPORT
#endif /* !STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM5_SUPPORT */
/* Form 1 */
#if defined(STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT)
# if defined(STLSOFT_CF_STD_LIBRARY_IS_STLPORT)
/* STLport is form 1 when not using the old form */
# if /* defined(__STL_CLASS_PARTIAL_SPECIALIZATION) || \
*/defined(_STLP_CLASS_PARTIAL_SPECIALIZATION)
# define STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM1_SUPPORT
# else /* ?_STLP_CLASS_PARTIAL_SPECIALIZATION */
# define STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM5_SUPPORT
# endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
# elif defined(STLSOFT_CF_STD_LIBRARY_IS_HP_RW)
/* Borland + HP/RogueWave standard library */
# define STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM1_SUPPORT
# elif defined(STLSOFT_CF_STD_LIBRARY_IS_HP_SGI_GNU)
/* GCC + Gnu/FSF standard library */
# define STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM1_SUPPORT
# elif defined(STLSOFT_CF_STD_LIBRARY_IS_MSL)
/* CodeWarrior + MSL */
# define STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM1_SUPPORT
# elif defined(STLSOFT_CF_STD_LIBRARY_IS_DINKUMWARE_VC) && \
( STLSOFT_CF_STD_LIBRARY_DINKUMWARE_VC_VERSION == STLSOFT_CF_DINKUMWARE_VC_VERSION_7_0 || \
STLSOFT_CF_STD_LIBRARY_DINKUMWARE_VC_VERSION == STLSOFT_CF_DINKUMWARE_VC_VERSION_7_1)
/* Visual C++ + Dinkumware */
# define STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM1_SUPPORT
# endif /* compiler / library */
/* Form 2 / Form 5 */
# if defined(STLSOFT_CF_STD_LIBRARY_IS_HP_SGI)
/* HP/SGI or HP/SGI/Comeau */
# if defined(__STL_CLASS_PARTIAL_SPECIALIZATION)
# define STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM2_SUPPORT
# else /* ?__STL_CLASS_PARTIAL_SPECIALIZATION */
# define STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM5_SUPPORT
# endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
# endif /* compiler / library */
/* Form 3 */
# if defined(STLSOFT_CF_STD_LIBRARY_IS_DINKUMWARE_VC) && \
( STLSOFT_CF_STD_LIBRARY_DINKUMWARE_VC_VERSION == STLSOFT_CF_DINKUMWARE_VC_VERSION_4_2 || \
STLSOFT_CF_STD_LIBRARY_DINKUMWARE_VC_VERSION == STLSOFT_CF_DINKUMWARE_VC_VERSION_5_0 || \
STLSOFT_CF_STD_LIBRARY_DINKUMWARE_VC_VERSION == STLSOFT_CF_DINKUMWARE_VC_VERSION_6_0)
/* Visual C++ + Dinkumware */
# define STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM3_SUPPORT
# endif /* compiler / library */
/* Form 4 */
/* stlsoft_reverse_iterator() */
# if defined(STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM1_SUPPORT) || \
defined(STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM2_SUPPORT)
# define stlsoft_reverse_iterator(I, V, R, P, D) stlsoft_ns_qual_std(reverse_iterator)<I>
# elif defined(STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM3_SUPPORT)
# define stlsoft_reverse_iterator(I, V, R, P, D) stlsoft_ns_qual_std(reverse_iterator)<I, V, R, P, D>
//# elif defined(STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM4_SUPPORT)
//# define stlsoft_reverse_iterator(I, V, R, P, D) stlsoft_ns_qual_std(reverse_iterator)<I, V, R, P, D>
# elif defined(STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM5_SUPPORT)
# define stlsoft_reverse_iterator(I, V, R, P, D) stlsoft_ns_qual_std(reverse_iterator)<I, V, R, D>
# else
# error reverse_iterator form not recognised
# endif /* compiler */
/* stlsoft_reverse_bidirectional_iterator() */
# if defined(STLSOFT_CF_STD_LIBRARY_IS_DINKUMWARE_VC) && \
( STLSOFT_CF_STD_LIBRARY_DINKUMWARE_VC_VERSION == STLSOFT_CF_DINKUMWARE_VC_VERSION_4_2 || \
STLSOFT_CF_STD_LIBRARY_DINKUMWARE_VC_VERSION == STLSOFT_CF_DINKUMWARE_VC_VERSION_5_0 || \
STLSOFT_CF_STD_LIBRARY_DINKUMWARE_VC_VERSION == STLSOFT_CF_DINKUMWARE_VC_VERSION_6_0)
# define stlsoft_reverse_bidirectional_iterator(I, V, R, P, D) stlsoft_ns_qual_std(reverse_bidirectional_iterator)<I, V, R, P, D>
# elif defined(STLSOFT_CF_STD_LIBRARY_IS_STLPORT) && \
!defined(_STLP_CLASS_PARTIAL_SPECIALIZATION)
# define stlsoft_reverse_bidirectional_iterator(I, V, R, P, D) stlsoft_ns_qual_std(reverse_bidirectional_iterator)<I, V, R, P, D>
# else
# define stlsoft_reverse_bidirectional_iterator(I, V, R, P, D) stlsoft_reverse_iterator(I, V, R, P, D)
# endif /* */
#endif /* STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */
/* /////////////////////////////////////////////////////////////////////////
* Iterators
*/
// class iterator_base
/** \brief Base type for <b><code>iterator</code></b> types
*
* \ingroup group__library__utility
*/
//
/** \brief This class abstract std::iterator functionality for deriving classes, hiding
* the inconsistencies and incompatibilities of the various compilers and/or
* libraries supported by the STLSoft libraries.
*
* \ingroup group__library__utility
*
* \param C The iterator category
* \param V The value type
* \param D The distance type
* \param P The pointer type
* \param R The reference type
*/
template< ss_typename_param_k C /* iterator category */
, ss_typename_param_k V /* value type */
, ss_typename_param_k D /* distance type */
, ss_typename_param_k P /* pointer */
, ss_typename_param_k R /* reference */
>
struct iterator_base
#if defined(STLSOFT_ITERATOR_ITERATOR_FORM1_SUPPORT)
: public stlsoft_ns_qual_std(iterator)<C, V, D, P, R>
#elif defined(STLSOFT_ITERATOR_ITERATOR_FORM2_SUPPORT)
: public stlsoft_ns_qual_std(iterator)<C, V, D>
#elif defined(STLSOFT_ITERATOR_ITERATOR_FORM3_SUPPORT)
/* Form 3 does not provide an iterator from which we can derive */
#else
# error Further iterator form discrimination required
#endif /* STLSOFT_ITERATOR_ITERATOR_FORM?_SUPPORT */
{
private:
#if defined(STLSOFT_ITERATOR_ITERATOR_FORM1_SUPPORT)
typedef stlsoft_ns_qual_std(iterator)<C, V, D, P, R> parent_class_type;
#elif defined(STLSOFT_ITERATOR_ITERATOR_FORM2_SUPPORT)
typedef stlsoft_ns_qual_std(iterator)<C, V, D> parent_class_type;
#elif defined(STLSOFT_ITERATOR_ITERATOR_FORM3_SUPPORT)
/* Form 3 does not provide an iterator from which we can derive */
typedef void parent_class_type;
#else
# error Further iterator form discrimination required
#endif /* STLSOFT_ITERATOR_ITERATOR_FORM?_SUPPORT */
# ifdef STLSOFT_CF_HAS_MEMBER_TYPE_SUPPORTED_XXXX
private:
// iterator_category
enum { has_member_iterator_category = 0 != has_iterator_category<parent_class_type>::value };
// value_type
enum { has_member_value_type = 0 != has_value_type<parent_class_type>::value };
// distance_type
enum { has_member_distance_type = 0 != has_distance_type<parent_class_type>::value };
// pointer
enum { has_member_pointer = 0 != has_pointer<parent_class_type>::value };
enum { has_member_pointer_type = 0 != has_pointer_type<parent_class_type>::value };
// reference
enum { has_member_reference = 0 != has_reference<parent_class_type>::value };
enum { has_member_reference_type = 0 != has_reference_type<parent_class_type>::value };
typedef C iterator_category_candidate;
typedef V value_type_candidate;
typedef D distance_candidate;
typedef P pointer_candidate;
typedef R reference_candidate;
public:
/// The pointer type
typedef ss_typename_type_k select_first_type_if<ss_typename_type_k fixer_pointer_type<parent_class_type, has_member_pointer_type>::pointer_type
, ss_typename_type_k fixer_pointer<parent_class_type, has_member_pointer>::pointer
, has_member_pointer_type
>::type pointer;
/// The reference type
typedef ss_typename_type_k select_first_type_if<ss_typename_type_k fixer_reference_type<parent_class_type, has_member_reference_type>::reference_type
, ss_typename_type_k fixer_reference<parent_class_type, has_member_reference>::reference
, has_member_reference_type
>::type reference;
# else /* ? STLSOFT_CF_HAS_MEMBER_TYPE_SUPPORTED */
public:
#if defined(STLSOFT_ITERATOR_ITERATOR_FORM3_SUPPORT)
typedef C iterator_category;
typedef V value_type;
typedef D difference_type;
typedef P pointer;
typedef R reference;
#else
/* Forms 1 or 2 */
typedef ss_typename_type_k parent_class_type::iterator_category iterator_category;
typedef ss_typename_type_k parent_class_type::value_type value_type;
# if defined(STLSOFT_ITERATOR_ITERATOR_FORM1_SUPPORT)
typedef ss_typename_type_k parent_class_type::difference_type difference_type;
typedef ss_typename_type_k parent_class_type::pointer pointer;
typedef ss_typename_type_k parent_class_type::reference reference;
# elif defined(STLSOFT_ITERATOR_ITERATOR_FORM2_SUPPORT)
typedef ss_typename_type_k parent_class_type::distance_type difference_type;
typedef P pointer;
typedef R reference;
# else
# error Further iterator form discrimination required
# endif /* STLSOFT_ITERATOR_ITERATOR_FORM?_SUPPORT */
#endif /* STLSOFT_ITERATOR_ITERATOR_FORM3_SUPPORT */
# endif /* STLSOFT_CF_HAS_MEMBER_TYPE_SUPPORTED */
/* These two are for compatibility with older non-standard implementations, and
* will be benignly ignored by anything not requiring them.
*/
typedef pointer pointer_type;
typedef reference reference_type;
};
#ifdef STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT
// reverse_iterator_base, const_reverse_iterator_base,
// reverse_bidirectional_iterator_base and const_reverse_bidirectional_iterator_base
//
// These classes act as the base for reverse iterators, insulating deriving
// classes from the inconsistencies and incompatibilities of the various
// compilers and/or libraries supported by the STLSoft libraries.
// class reverse_iterator_base
/** \brief Base type for <b><code>reverse_iterator</code></b> types
*
* \ingroup group__library__utility
*/
//
/** \brief This class acts as the base for reverse iterators, insulating deriving
* classes from the inconsistencies and incompatibilities of the various
* compilers and/or libraries supported by the STLSoft libraries.
*
* \ingroup group__library__utility
*
* \param I The iterator type
* \param V The value type
* \param R The reference type
* \param P The pointer type
* \param D The distance type
*/
template< ss_typename_param_k I /* iterator */
, ss_typename_param_k V /* value type */
, ss_typename_param_k R /* reference */
, ss_typename_param_k P /* pointer */
, ss_typename_param_k D /* distance type */
>
struct reverse_iterator_base
: public stlsoft_reverse_iterator(I, V, R, P, D)
{
public:
typedef stlsoft_reverse_iterator(I, V, R, P, D) parent_class_type;
typedef ss_typename_type_k parent_class_type::iterator_category iterator_category;
typedef ss_typename_type_k parent_class_type::value_type value_type;
# if defined(STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM3_SUPPORT)
typedef ss_typename_type_k parent_class_type::distance_type difference_type;
typedef ss_typename_type_k parent_class_type::pointer_type pointer;
typedef ss_typename_type_k parent_class_type::reference_type reference;
# else /* ? STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM3_SUPPORT */
typedef ss_typename_type_k parent_class_type::difference_type difference_type;
typedef ss_typename_type_k parent_class_type::pointer pointer;
typedef ss_typename_type_k parent_class_type::reference reference;
# endif /* STLSOFT_ITERATOR_REVERSE_ITERATOR_FORM3_SUPPORT */
/* These two are for compatibility with older non-standard implementations, and
* will be benignly ignored by anything not requiring them.
*/
typedef pointer pointer_type;
typedef reference reference_type;
// Construction
public:
/// Constructor
ss_explicit_k reverse_iterator_base(I i)
: parent_class_type(i)
{}
};
// class const_reverse_iterator_base
/** \brief Base type for <b><code>const_reverse_iterator</code></b> types
*
* \ingroup group__library__utility
*/
//
/** \brief This class acts as the base for const reverse iterators, insulating deriving
* classes from the inconsistencies and incompatibilities of the various
* compilers and/or libraries supported by the STLSoft libraries.
*
* \ingroup group__library__utility
*
* \param I The iterator type
* \param V The value type
* \param R The reference type
* \param P The pointer type
* \param D The distance type
*/
template< ss_typename_param_k I /* iterator */
, ss_typename_param_k V /* value type */
, ss_typename_param_k R /* reference */
, ss_typename_param_k P /* pointer */
, ss_typename_param_k D /* distance type */
>
struct const_reverse_iterator_base // For all current compilers/libraries, ...
: public reverse_iterator_base<I, V, R, P, D> // ... this is the same as reverse_iterator_base
{
public:
typedef reverse_iterator_base<I, V, R, P, D> parent_class_type;
/// The iterator category type
typedef ss_typename_type_k parent_class_type::iterator_category iterator_category;
/// The value type
typedef ss_typename_type_k parent_class_type::value_type value_type;
/// The difference type
typedef ss_typename_type_k parent_class_type::difference_type difference_type;
/// The pointer type
typedef ss_typename_type_k parent_class_type::pointer pointer;
/// The reference type
typedef ss_typename_type_k parent_class_type::reference reference;
/* These two are for compatibility with older non-standard implementations, and
* will be benignly ignored by anything not requiring them.
*/
/// The alternate pointer type (for backwards compatibility)
typedef ss_typename_type_k parent_class_type::pointer_type pointer_type;
/// The alternate reference type (for backwards compatibility)
typedef ss_typename_type_k parent_class_type::reference_type reference_type;
// Construction
public:
/// Constructor
ss_explicit_k const_reverse_iterator_base(I i)
: parent_class_type(i)
{}
};
// class reverse_bidirectional_iterator_base
/** \brief Base type for <b><code>reverse_bidirectional_iterator</code></b> types
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -