iterator_traits.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. *
  3. * Copyright (c) 1998-2002
  4. * John Maddock
  5. *
  6. * Use, modification and distribution are subject to the
  7. * Boost Software License, Version 1.0. (See accompanying file
  8. * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. *
  10. */
  11. /*
  12. * LOCATION: see http://www.boost.org for most recent version.
  13. * FILE iterator_traits.cpp
  14. * VERSION see <boost/version.hpp>
  15. * DESCRIPTION: Declares iterator traits workarounds.
  16. */
  17. #ifndef BOOST_REGEX_V4_ITERATOR_TRAITS_HPP
  18. #define BOOST_REGEX_V4_ITERATOR_TRAITS_HPP
  19. #ifdef BOOST_MSVC
  20. #pragma warning(push)
  21. #pragma warning(disable: 4103)
  22. #endif
  23. #ifdef BOOST_HAS_ABI_HEADERS
  24. # include BOOST_ABI_PREFIX
  25. #endif
  26. #ifdef BOOST_MSVC
  27. #pragma warning(pop)
  28. #endif
  29. namespace boost{
  30. namespace BOOST_REGEX_DETAIL_NS{
  31. #if defined(BOOST_NO_STD_ITERATOR_TRAITS)
  32. template <class T>
  33. struct regex_iterator_traits
  34. {
  35. typedef typename T::iterator_category iterator_category;
  36. typedef typename T::value_type value_type;
  37. #if !defined(BOOST_NO_STD_ITERATOR)
  38. typedef typename T::difference_type difference_type;
  39. typedef typename T::pointer pointer;
  40. typedef typename T::reference reference;
  41. #else
  42. typedef std::ptrdiff_t difference_type;
  43. typedef value_type* pointer;
  44. typedef value_type& reference;
  45. #endif
  46. };
  47. template <class T>
  48. struct pointer_iterator_traits
  49. {
  50. typedef std::ptrdiff_t difference_type;
  51. typedef T value_type;
  52. typedef T* pointer;
  53. typedef T& reference;
  54. typedef std::random_access_iterator_tag iterator_category;
  55. };
  56. template <class T>
  57. struct const_pointer_iterator_traits
  58. {
  59. typedef std::ptrdiff_t difference_type;
  60. typedef T value_type;
  61. typedef const T* pointer;
  62. typedef const T& reference;
  63. typedef std::random_access_iterator_tag iterator_category;
  64. };
  65. template<>
  66. struct regex_iterator_traits<char*> : pointer_iterator_traits<char>{};
  67. template<>
  68. struct regex_iterator_traits<const char*> : const_pointer_iterator_traits<char>{};
  69. template<>
  70. struct regex_iterator_traits<wchar_t*> : pointer_iterator_traits<wchar_t>{};
  71. template<>
  72. struct regex_iterator_traits<const wchar_t*> : const_pointer_iterator_traits<wchar_t>{};
  73. //
  74. // the follwoing are needed for ICU support:
  75. //
  76. template<>
  77. struct regex_iterator_traits<unsigned char*> : pointer_iterator_traits<char>{};
  78. template<>
  79. struct regex_iterator_traits<const unsigned char*> : const_pointer_iterator_traits<char>{};
  80. template<>
  81. struct regex_iterator_traits<int*> : pointer_iterator_traits<int>{};
  82. template<>
  83. struct regex_iterator_traits<const int*> : const_pointer_iterator_traits<int>{};
  84. #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T
  85. template<>
  86. struct regex_iterator_traits<unsigned short*> : pointer_iterator_traits<unsigned short>{};
  87. template<>
  88. struct regex_iterator_traits<const unsigned short*> : const_pointer_iterator_traits<unsigned short>{};
  89. #endif
  90. #if defined(__SGI_STL_PORT) && defined(__STL_DEBUG)
  91. template<>
  92. struct regex_iterator_traits<std::string::iterator> : pointer_iterator_traits<char>{};
  93. template<>
  94. struct regex_iterator_traits<std::string::const_iterator> : const_pointer_iterator_traits<char>{};
  95. #ifndef BOOST_NO_STD_WSTRING
  96. template<>
  97. struct regex_iterator_traits<std::wstring::iterator> : pointer_iterator_traits<wchar_t>{};
  98. template<>
  99. struct regex_iterator_traits<std::wstring::const_iterator> : const_pointer_iterator_traits<wchar_t>{};
  100. #endif // BOOST_NO_WSTRING
  101. #endif // stport
  102. #else
  103. template <class T>
  104. struct regex_iterator_traits : public std::iterator_traits<T> {};
  105. #endif
  106. } // namespace BOOST_REGEX_DETAIL_NS
  107. } // namespace boost
  108. #ifdef BOOST_MSVC
  109. #pragma warning(push)
  110. #pragma warning(disable: 4103)
  111. #endif
  112. #ifdef BOOST_HAS_ABI_HEADERS
  113. # include BOOST_ABI_SUFFIX
  114. #endif
  115. #ifdef BOOST_MSVC
  116. #pragma warning(pop)
  117. #endif
  118. #endif