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