Added
Link Here
|
1 |
--- include/SFML/System/String.hpp.orig 2023-10-30 00:03:26 UTC |
2 |
+++ include/SFML/System/String.hpp |
3 |
@@ -34,6 +34,129 @@ |
4 |
#include <locale> |
5 |
#include <string> |
6 |
|
7 |
+namespace std |
8 |
+{ |
9 |
+ |
10 |
+namespace // anonymous |
11 |
+{ |
12 |
+ |
13 |
+template<class CharType, class IntType, IntType EOFVal> |
14 |
+struct char_traits_base |
15 |
+{ |
16 |
+ using char_type = CharType; |
17 |
+ using int_type = IntType; |
18 |
+ using off_type = streamoff; |
19 |
+ using pos_type = fpos<mbstate_t>; |
20 |
+ using state_type = mbstate_t; |
21 |
+ |
22 |
+ static inline constexpr void assign(char_type& c1, const char_type& c2) noexcept |
23 |
+ { |
24 |
+ c1 = c2; |
25 |
+ } |
26 |
+ |
27 |
+ static inline constexpr bool eq(char_type c1, char_type c2) noexcept |
28 |
+ { |
29 |
+ return c1 == c2; |
30 |
+ } |
31 |
+ |
32 |
+ static inline constexpr bool lt(char_type c1, char_type c2) noexcept |
33 |
+ { |
34 |
+ return c1 < c2; |
35 |
+ } |
36 |
+ |
37 |
+ static constexpr int compare(const char_type* lhs, const char_type* rhs, size_t count) noexcept |
38 |
+ { |
39 |
+ for (; count; --count, ++lhs, ++rhs) |
40 |
+ { |
41 |
+ if (lt(*lhs, *rhs)) |
42 |
+ return -1; |
43 |
+ if (lt(*rhs, *lhs)) |
44 |
+ return 1; |
45 |
+ } |
46 |
+ return 0; |
47 |
+ } |
48 |
+ |
49 |
+ static inline size_t constexpr length(const char_type* s) noexcept |
50 |
+ { |
51 |
+ size_t i = 0; |
52 |
+ for (; s[i] != '\0'; ++i) |
53 |
+ { |
54 |
+ } |
55 |
+ return i; |
56 |
+ } |
57 |
+ |
58 |
+ static constexpr const char_type* find(const char_type* s, size_t n, const char_type& a) noexcept |
59 |
+ { |
60 |
+ for (; n; --n) |
61 |
+ { |
62 |
+ if (*s == a) |
63 |
+ return s; |
64 |
+ ++s; |
65 |
+ } |
66 |
+ return nullptr; |
67 |
+ } |
68 |
+ |
69 |
+ static inline char_type* move(char_type* s1, const char_type* s2, size_t n) noexcept |
70 |
+ { |
71 |
+ return reinterpret_cast<char_type*>(__builtin_memmove(s1, s2, n * sizeof(char_type))); |
72 |
+ } |
73 |
+ |
74 |
+ static inline char_type* copy(char_type* s1, const char_type* s2, size_t n) noexcept |
75 |
+ { |
76 |
+ __builtin_memmove(s1, s2, n * sizeof(char_type)); |
77 |
+ return s1; |
78 |
+ } |
79 |
+ |
80 |
+ static inline char_type* assign(char_type* s, size_t n, char_type a) noexcept |
81 |
+ { |
82 |
+ std::fill_n(s, n, a); |
83 |
+ return s; |
84 |
+ } |
85 |
+ |
86 |
+ static inline constexpr int_type not_eof(int_type c) noexcept |
87 |
+ { |
88 |
+ return eq_int_type(c, eof()) ? ~eof() : c; |
89 |
+ } |
90 |
+ |
91 |
+ static inline constexpr char_type to_char_type(int_type c) noexcept |
92 |
+ { |
93 |
+ return char_type(c); |
94 |
+ } |
95 |
+ |
96 |
+ static inline constexpr int_type to_int_type(char_type c) noexcept |
97 |
+ { |
98 |
+ return int_type(c); |
99 |
+ } |
100 |
+ |
101 |
+ static inline constexpr bool eq_int_type(int_type c1, int_type c2) noexcept |
102 |
+ { |
103 |
+ return c1 == c2; |
104 |
+ } |
105 |
+ |
106 |
+ static inline constexpr int_type eof() noexcept |
107 |
+ { |
108 |
+ return int_type(EOF); |
109 |
+ } |
110 |
+}; |
111 |
+ |
112 |
+} // namespace anonymous |
113 |
+ |
114 |
+template<> |
115 |
+struct char_traits<unsigned char> : char_traits_base<unsigned char, unsigned int, static_cast<unsigned int>(EOF)> |
116 |
+{ |
117 |
+}; |
118 |
+ |
119 |
+template<> |
120 |
+struct char_traits<unsigned short> : char_traits_base<unsigned short, unsigned int, static_cast<unsigned int>(0xFFFF)> |
121 |
+{ |
122 |
+}; |
123 |
+ |
124 |
+template<> |
125 |
+struct char_traits<unsigned int> : char_traits_base<unsigned int, unsigned int, static_cast<unsigned int>(0xFFFFFFFF)> |
126 |
+{ |
127 |
+}; |
128 |
+ |
129 |
+} // namespace std |
130 |
|
131 |
namespace sf |
132 |
{ |