]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // type_traits.hpp | |
3 | // | |
4 | // Copyright 2008 Eric Niebler. Distributed under the Boost | |
5 | // Software License, Version 1.0. (See accompanying file | |
6 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
7 | ||
8 | #ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TYPE_TRAITS_HPP_EAN_10_04_2005 | |
9 | #define BOOST_XPRESSIVE_DETAIL_STATIC_TYPE_TRAITS_HPP_EAN_10_04_2005 | |
10 | ||
11 | // MS compatible compilers support #pragma once | |
12 | #if defined(_MSC_VER) | |
13 | # pragma once | |
14 | #endif | |
15 | ||
16 | #include <string> | |
17 | #include <boost/config.hpp> | |
18 | #include <boost/mpl/bool.hpp> | |
19 | #include <boost/iterator/iterator_traits.hpp> | |
20 | #include <boost/type_traits/is_convertible.hpp> | |
21 | #include <boost/xpressive/detail/detail_fwd.hpp> | |
22 | ||
23 | namespace boost { namespace xpressive { namespace detail | |
24 | { | |
25 | ||
26 | /////////////////////////////////////////////////////////////////////////////// | |
27 | // is_static_xpression | |
28 | // | |
29 | template<typename T> | |
30 | struct is_static_xpression | |
31 | : mpl::false_ | |
32 | { | |
33 | }; | |
34 | ||
35 | template<typename Matcher, typename Next> | |
36 | struct is_static_xpression<static_xpression<Matcher, Next> > | |
37 | : mpl::true_ | |
38 | { | |
39 | }; | |
40 | ||
41 | template<typename Top, typename Next> | |
42 | struct is_static_xpression<stacked_xpression<Top, Next> > | |
43 | : mpl::true_ | |
44 | { | |
45 | }; | |
46 | ||
47 | ////////////////////////////////////////////////////////////////////////// | |
48 | // is_random | |
49 | // | |
50 | template<typename BidiIter> | |
51 | struct is_random | |
52 | : is_convertible | |
53 | < | |
54 | typename iterator_category<BidiIter>::type | |
55 | , std::random_access_iterator_tag | |
56 | > | |
57 | { | |
58 | }; | |
59 | ||
60 | ////////////////////////////////////////////////////////////////////////// | |
61 | // is_string_iterator | |
62 | // | |
63 | template<typename Iter> | |
64 | struct is_string_iterator | |
65 | : mpl::false_ | |
66 | { | |
67 | }; | |
68 | ||
69 | template<> | |
70 | struct is_string_iterator<std::string::iterator> | |
71 | : mpl::true_ | |
72 | { | |
73 | }; | |
74 | ||
75 | template<> | |
76 | struct is_string_iterator<std::string::const_iterator> | |
77 | : mpl::true_ | |
78 | { | |
79 | }; | |
80 | ||
81 | #ifndef BOOST_NO_STD_WSTRING | |
82 | template<> | |
83 | struct is_string_iterator<std::wstring::iterator> | |
84 | : mpl::true_ | |
85 | { | |
86 | }; | |
87 | ||
88 | template<> | |
89 | struct is_string_iterator<std::wstring::const_iterator> | |
90 | : mpl::true_ | |
91 | { | |
92 | }; | |
93 | #endif | |
94 | ||
95 | /////////////////////////////////////////////////////////////////////////////// | |
96 | // is_char | |
97 | // | |
98 | template<typename T> | |
99 | struct is_char | |
100 | : mpl::false_ | |
101 | {}; | |
102 | ||
103 | template<> | |
104 | struct is_char<char> | |
105 | : mpl::true_ | |
106 | {}; | |
107 | ||
108 | template<> | |
109 | struct is_char<wchar_t> | |
110 | : mpl::true_ | |
111 | {}; | |
112 | ||
113 | }}} // namespace boost::xpressive::detail | |
114 | ||
115 | #endif |