]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/regex/test/concepts/test_bug_11988.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / regex / test / concepts / test_bug_11988.cpp
1 /*
2 *
3 * Copyright (c) 2016
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 #include <boost/config.hpp>
13
14 #ifndef BOOST_NO_CXX11_CHAR32_T
15
16 #include <cstddef>
17
18 namespace boost {
19
20 std::size_t hash_value(char32_t const& c) { return c; }
21
22 }
23
24 #include <boost/regex.hpp>
25
26 struct char32_traits
27 {
28 typedef char32_t char_type;
29 typedef std::size_t size_type;
30 typedef std::vector<char32_t> string_type;
31 typedef int locale_type; // not used
32 typedef unsigned char_class_type;
33
34 static size_type length(const char32_t* p)
35 {
36 size_type result = 0;
37 while(*p)
38 {
39 ++p;
40 ++result;
41 }
42 return result;
43 }
44 static char_type translate(char_type c) { return c; }
45 static char_type translate_nocase(char_type c) { return c; }
46 static string_type transform(const char32_t* p1, const char32_t* p2)
47 {
48 return string_type(p1, p2);
49 }
50 static string_type transform_primary(const char32_t* p1, const char32_t* p2)
51 {
52 return string_type(p1, p2);
53 }
54 static char_class_type lookup_classname(const char32_t* p1, const char32_t* p2)
55 {
56 std::string s(p1, p2);
57 return boost::c_regex_traits<char>::lookup_classname(s.c_str(), s.c_str() + s.length());
58 return 0;
59 }
60 static string_type lookup_collatename(const char32_t* p1, const char32_t* p2)
61 {
62 return string_type(p1, p2);
63 }
64 static bool isctype(char_type c, char_class_type t)
65 {
66 if(c < 0xff)
67 return boost::c_regex_traits<char>::isctype(c, t);
68 return false;
69 }
70 static boost::intmax_t value(char_type c, int radix)
71 {
72 switch(radix)
73 {
74 case 8:
75 if((c >= '0') && (c <= '7'))
76 return c - '0';
77 break;
78 case 10:
79 if((c >= '0') && (c <= '9'))
80 return c - '0';
81 break;
82 case 16:
83 if((c >= '0') && (c <= '9'))
84 return c - '0';
85 if((c >= 'a') && (c <= 'f'))
86 return (c - 'a') + 10;
87 if((c >= 'A') && (c <= 'F'))
88 return (c - 'A') + 10;
89 break;
90 }
91 return -1;
92 }
93 static locale_type imbue(locale_type) { return 0; }
94 static locale_type getloc() { return 0; }
95 };
96
97
98 int main()
99 {
100 char32_t big_char[] = { 0xF, 0xFF, 0xFFF, 0xFFFF, 0xFFFFF, 0xFFFFFF, 0xFFFFFFF, 0xFFFFFFFF, 0 };
101
102 boost::basic_regex<char32_t, char32_traits> e(U"\\x{F}\\x{FF}\\x{FFF}\\x{FFFF}\\x{FFFFF}\\x{FFFFFF}\\x{FFFFFFF}\\x{FFFFFFFF}");
103
104 if(!regex_match(big_char, e))
105 {
106 return 1;
107 }
108 return 0;
109 }
110
111 #else
112
113 int main() { return 0; }
114
115 #endif