📄 iterator_helper.hpp
字号:
*
* \ingroup group__library__utility
*/
//
/** \brief This class acts as the base for reverse bidirectional 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_bidirectional_iterator_base
: public stlsoft_reverse_bidirectional_iterator(I, V, R, P, D)
{
public:
typedef stlsoft_reverse_bidirectional_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_bidirectional_iterator_base(I i)
: parent_class_type(i)
{}
};
// class const_reverse_bidirectional_iterator_base
/** \brief Base type for <b><code>const_reverse_bidirectional_iterator</code></b> types
*
* \ingroup group__library__utility
*/
//
/** \brief This class acts as the base for const reverse bidirectional 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_bidirectional_iterator_base // For all current compilers/libraries, ...
: public reverse_bidirectional_iterator_base<I, V, R, P, D> // ... this is the same as reverse_iterator_base
{
public:
typedef reverse_bidirectional_iterator_base<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;
typedef ss_typename_type_k parent_class_type::difference_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;
/* These two are for compatibility with older non-standard implementations, and
* will be benignly ignored by anything not requiring them.
*/
typedef ss_typename_type_k parent_class_type::pointer pointer_type;
typedef ss_typename_type_k parent_class_type::reference reference_type;
// Construction
public:
/// Constructor
ss_explicit_k const_reverse_bidirectional_iterator_base(I i)
: parent_class_type(i)
{}
};
#endif /* STLSOFT_CF_BIDIRECTIONAL_ITERATOR_SUPPORT */
/* /////////////////////////////////////////////////////////////////////////
* Random access iterator support
*/
// This is all some hideous kludge caused by Dinkumware's standard library's
// failure to leave behind any definitive discriminatable vestige of its
// presence.
//
// The discriminators are determined in stlsoft/util/std/library_discriminator.hpp
#ifdef _STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES
#ifndef _STLSOFT_NO_NAMESPACE
} // namespace stlsoft
#endif /* _STLSOFT_NO_NAMESPACE */
template< ss_typename_param_k _Ty
, ss_typename_param_k _Diff
, ss_typename_param_k _Pointer
, ss_typename_param_k _Reference
, ss_typename_param_k _Pointer2
, ss_typename_param_k _Reference2
>
class _Ptrit
{
public:
typedef _Pointer iterator_type;
private:
char x[1024];
};
namespace std
{
namespace test_dinkumware
{
template< ss_typename_param_k T1
, ss_typename_param_k T2
, bool S
>
struct select_type
{
typedef T1 selected_type;
};
#ifdef STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT
template< ss_typename_param_k T1
, ss_typename_param_k T2
>
struct select_type<T1, T2, false>
{
typedef T2 selected_type;
};
#endif // STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT
template< class V
, class P
, class R
>
class _Ptrit_tdkw
{
typedef _Ptrit<V, stlsoft_ns_qual(ss_ptrdiff_t), P, R, P, R> _Ptrit_type;
public:
typedef ss_typename_type_k select_type<_Ptrit_type, P, sizeof(_Ptrit_type) < 1024>::selected_type iterator_type;
};
} // namespace test_dinkumware
} // namespace std
#ifndef _STLSOFT_NO_NAMESPACE
namespace stlsoft
{
#endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !_STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES */
/** \brief Pointer iterator type
*
* \ingroup group__library__utility
*
* \param V The value type
* \param P The pointer type
* \param R The reference type
*/
template< ss_typename_param_k V
, ss_typename_param_k P
, ss_typename_param_k R
>
struct pointer_iterator
{
#if defined(_STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES) && \
!defined(STLSOFT_CF_STD_LIBRARY_IS_STLPORT)
# if defined(_STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES_1300)
typedef std::test_dinkumware::_Ptrit_tdkw<V, P, R>::iterator_type type;
# else
typedef P type;
# endif /* _STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES_1300 */
#elif defined(STLSOFT_COMPILER_IS_MSVC) && \
!defined(STLSOFT_CF_STD_LIBRARY_IS_STLPORT) && \
defined(_XUTILITY_) && \
_MSC_VER == 1300
typedef std::_Ptrit<V, stlsoft_ns_qual(ss_ptrdiff_t), P, R, P, R> type;
#else
typedef P type;
#endif /* !_STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES */
#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
public:
// For backwards compatibility
typedef type iterator_type;
#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
};
/* ////////////////////////////////////////////////////////////////////// */
#if defined(STLSOFT_COMPILER_IS_DMC) && \
!defined(STLSOFT_CF_STD_LIBRARY_IS_STLPORT)
template< ss_typename_param_k V
, ss_typename_param_k P
, ss_typename_param_k R
>
inline random_access_iterator_tag iterator_category(pointer_iterator<V, P, R>::type const&)
{
return random_access_iterator_tag();
}
template< ss_typename_param_k V
, ss_typename_param_k P
, ss_typename_param_k R
>
inline stlsoft_ns_qual(ss_ptrdiff_t) *distance_type(pointer_iterator<V, P, R>::type const&)
{
return static_cast<stlsoft_ns_qual(ss_ptrdiff_t)*>(0);
}
#endif /* STLSOFT_COMPILER_IS_DMC && !STLSOFT_CF_STD_LIBRARY_IS_STLPORT */
/* ////////////////////////////////////////////////////////////////////// */
/** \brief Iterator category obtainer
*
* \ingroup group__library__utility
*
* \param I The iterator type
* \param i The iterator instance
*/
#if defined(STLSOFT_CF_STD_LIBRARY_IS_DINKUMWARE_VC)
# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(_Iter_cat)(i))
# define stlsoft_iterator_query_category_ptr(I, i) (&stlsoft_ns_qual_std(_Iter_cat)(i))
//#elif defined(STLSOFT_CF_STD_LIBRARY_IS_STLPORT)
//# define stlsoft_iterator_query_category(I, i) (*static_cast<std::iterator_traits<I>::iterator_category*>(0))
//#elif defined(STLSOFT_COMPILER_IS_BORLAND) // Change this to STLSOFT_CF_STD_LIBRARY_IS_SGI_RW
//# define stlsoft_iterator_query_category(I, i) (*static_cast<std::iterator_traits<I>::iterator_category*>(0))
#else /* ? library */
//#if defined(STLSOFT_CF_STD_LIBRARY_IS_STLPORT)
# define stlsoft_iterator_query_category(I, i) (*static_cast<ss_typename_type_k std::iterator_traits<I>::iterator_category*>(0))
# define stlsoft_iterator_query_category_ptr(I, i) (static_cast<ss_typename_type_k std::iterator_traits<I>::iterator_category*>(0))
//#else
//# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_category)(i))
#endif /* library / compiler */
#if 0
# if defined(STLSOFT_COMPILER_IS_DMC)
# if defined(STLSOFT_CF_STD_LIBRARY_IS_STLPORT)
# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_traits)<I>::iterator_category())
//# error Digital Mars with STLport not yet supported
# else
# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_category)(i))
# endif /* */
# elif defined(STLSOFT_COMPILER_IS_COMO) || \
defined(STLSOFT_COMPILER_IS_INTEL)
# if defined(STLSOFT_CF_STD_LIBRARY_IS_STLPORT)
# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_traits)<I>::iterator_category())
# elif defined(_STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES)
# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(_Iter_cat)(i))
# else
# error
# endif /* */
# elif defined(STLSOFT_COMPILER_IS_MSVC)
# if defined(STLSOFT_CF_STD_LIBRARY_IS_STLPORT)
# if _MSC_VER < 1300
# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_category)(i))
# else
# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_category)(i))
# endif /* _MSC_VER < 1300 */
# elif defined(_STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES)
# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(_Iter_cat)(i))
# elif(_MSC_VER >= 1310)
# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_traits)<I>::iterator_category())
# elif(_MSC_VER >= 1200)
# error
# endif /* */
# else
# define stlsoft_iterator_query_category(I, i) (stlsoft_ns_qual_std(iterator_traits)<I>::iterator_category())
# endif /* _STLSOFT_CF_MIGHT_BE_DINKUMWARE_MS_NAUGHTIES && !STLSOFT_CF_STD_LIBRARY_IS_STLPORT */
#endif /* 0 */
#if 0
template <ss_typename_param_k T>
struct queried_iterator_category
{
};
template <ss_typename_param_k T>
query_iterator_category
#endif /* 0 */
/* ////////////////////////////////////////////////////////////////////// */
#ifndef _STLSOFT_NO_NAMESPACE
} // namespace stlsoft
#endif /* _STLSOFT_NO_NAMESPACE */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER */
/* ////////////////////////////////////////////////////////////////////// */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -