|
1 /* |
|
2 * |
|
3 * Copyright (c) 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 regex_match.hpp |
|
15 * VERSION see <boost/version.hpp> |
|
16 * DESCRIPTION: Iterator traits for selecting an iterator type as |
|
17 * an integral constant expression. |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef BOOST_REGEX_ITERATOR_CATEGORY_HPP |
|
22 #define BOOST_REGEX_ITERATOR_CATEGORY_HPP |
|
23 |
|
24 #include <iterator> |
|
25 #include <boost/type_traits/is_convertible.hpp> |
|
26 #include <boost/type_traits/is_pointer.hpp> |
|
27 |
|
28 namespace boost{ |
|
29 namespace detail{ |
|
30 |
|
31 template <class I> |
|
32 struct is_random_imp |
|
33 { |
|
34 private: |
|
35 typedef typename std::iterator_traits<I>::iterator_category cat; |
|
36 public: |
|
37 BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible<cat*, std::random_access_iterator_tag*>::value)); |
|
38 }; |
|
39 |
|
40 template <class I> |
|
41 struct is_random_pointer_imp |
|
42 { |
|
43 BOOST_STATIC_CONSTANT(bool, value = true); |
|
44 }; |
|
45 |
|
46 template <bool is_pointer_type> |
|
47 struct is_random_imp_selector |
|
48 { |
|
49 template <class I> |
|
50 struct rebind |
|
51 { |
|
52 typedef is_random_imp<I> type; |
|
53 }; |
|
54 }; |
|
55 |
|
56 template <> |
|
57 struct is_random_imp_selector<true> |
|
58 { |
|
59 template <class I> |
|
60 struct rebind |
|
61 { |
|
62 typedef is_random_pointer_imp<I> type; |
|
63 }; |
|
64 }; |
|
65 |
|
66 } |
|
67 |
|
68 template <class I> |
|
69 struct is_random_access_iterator |
|
70 { |
|
71 private: |
|
72 typedef detail::is_random_imp_selector< ::boost::is_pointer<I>::value> selector; |
|
73 typedef typename selector::template rebind<I> bound_type; |
|
74 typedef typename bound_type::type answer; |
|
75 public: |
|
76 BOOST_STATIC_CONSTANT(bool, value = answer::value); |
|
77 }; |
|
78 |
|
79 #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION |
|
80 template <class I> |
|
81 const bool is_random_access_iterator<I>::value; |
|
82 #endif |
|
83 |
|
84 } |
|
85 |
|
86 #endif |
|
87 |