blob: 6795b3505b33f1b61b4c93be1dfd1393e9800238 [file] [log] [blame]
Jeff Thompson86b6d642013-10-17 15:01:56 -07001/*
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 /*
13 * LOCATION: see http://www.boost.org for most recent version.
14 * FILE iterator_traits.cpp
15 * VERSION see <ndnboost/version.hpp>
16 * DESCRIPTION: Declares iterator traits workarounds.
17 */
18
19#ifndef NDNBOOST_REGEX_V4_ITERATOR_TRAITS_HPP
20#define NDNBOOST_REGEX_V4_ITERATOR_TRAITS_HPP
21
22#ifdef NDNBOOST_MSVC
23#pragma warning(push)
24#pragma warning(disable: 4103)
25#endif
26#ifdef NDNBOOST_HAS_ABI_HEADERS
27# include NDNBOOST_ABI_PREFIX
28#endif
29#ifdef NDNBOOST_MSVC
30#pragma warning(pop)
31#endif
32
33namespace ndnboost{
34namespace re_detail{
35
36#if defined(NDNBOOST_NO_STD_ITERATOR_TRAITS) || defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
37
38template <class T>
39struct regex_iterator_traits
40{
41 typedef typename T::iterator_category iterator_category;
42 typedef typename T::value_type value_type;
43#if !defined(NDNBOOST_NO_STD_ITERATOR)
44 typedef typename T::difference_type difference_type;
45 typedef typename T::pointer pointer;
46 typedef typename T::reference reference;
47#else
48 typedef std::ptrdiff_t difference_type;
49 typedef value_type* pointer;
50 typedef value_type& reference;
51#endif
52};
53
54template <class T>
55struct pointer_iterator_traits
56{
57 typedef std::ptrdiff_t difference_type;
58 typedef T value_type;
59 typedef T* pointer;
60 typedef T& reference;
61 typedef std::random_access_iterator_tag iterator_category;
62};
63template <class T>
64struct const_pointer_iterator_traits
65{
66 typedef std::ptrdiff_t difference_type;
67 typedef T value_type;
68 typedef const T* pointer;
69 typedef const T& reference;
70 typedef std::random_access_iterator_tag iterator_category;
71};
72
73template<>
74struct regex_iterator_traits<char*> : pointer_iterator_traits<char>{};
75template<>
76struct regex_iterator_traits<const char*> : const_pointer_iterator_traits<char>{};
77template<>
78struct regex_iterator_traits<wchar_t*> : pointer_iterator_traits<wchar_t>{};
79template<>
80struct regex_iterator_traits<const wchar_t*> : const_pointer_iterator_traits<wchar_t>{};
81//
82// the follwoing are needed for ICU support:
83//
84template<>
85struct regex_iterator_traits<unsigned char*> : pointer_iterator_traits<char>{};
86template<>
87struct regex_iterator_traits<const unsigned char*> : const_pointer_iterator_traits<char>{};
88template<>
89struct regex_iterator_traits<int*> : pointer_iterator_traits<int>{};
90template<>
91struct regex_iterator_traits<const int*> : const_pointer_iterator_traits<int>{};
92
93#ifdef NDNBOOST_REGEX_HAS_OTHER_WCHAR_T
94template<>
95struct regex_iterator_traits<unsigned short*> : pointer_iterator_traits<unsigned short>{};
96template<>
97struct regex_iterator_traits<const unsigned short*> : const_pointer_iterator_traits<unsigned short>{};
98#endif
99
100#if defined(__SGI_STL_PORT) && defined(__STL_DEBUG)
101template<>
102struct regex_iterator_traits<std::string::iterator> : pointer_iterator_traits<char>{};
103template<>
104struct regex_iterator_traits<std::string::const_iterator> : const_pointer_iterator_traits<char>{};
105#ifndef NDNBOOST_NO_STD_WSTRING
106template<>
107struct regex_iterator_traits<std::wstring::iterator> : pointer_iterator_traits<wchar_t>{};
108template<>
109struct regex_iterator_traits<std::wstring::const_iterator> : const_pointer_iterator_traits<wchar_t>{};
110#endif // NDNBOOST_NO_WSTRING
111#endif // stport
112
113#else
114
115template <class T>
116struct regex_iterator_traits : public std::iterator_traits<T> {};
117
118#endif
119
120} // namespace re_detail
121} // namespace ndnboost
122
123#ifdef NDNBOOST_MSVC
124#pragma warning(push)
125#pragma warning(disable: 4103)
126#endif
127#ifdef NDNBOOST_HAS_ABI_HEADERS
128# include NDNBOOST_ABI_SUFFIX
129#endif
130#ifdef NDNBOOST_MSVC
131#pragma warning(pop)
132#endif
133
134#endif
135