Skip to content

Commit b43114d

Browse files
committed
Constrain all CharType template parameters in string library
1 parent 70185e7 commit b43114d

11 files changed

+137
-128
lines changed

fly/types/string/detail/classifier.hpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace fly::detail {
1414
* @author Timothy Flynn ([email protected])
1515
* @version January 3, 2021
1616
*/
17-
template <typename CharType>
17+
template <fly::StandardCharacter CharType>
1818
class BasicClassifier
1919
{
2020
using traits = detail::BasicStringTraits<CharType>;
@@ -186,7 +186,7 @@ class BasicClassifier
186186
};
187187

188188
//==================================================================================================
189-
template <typename CharType>
189+
template <fly::StandardCharacter CharType>
190190
template <fly::StandardStringLike T>
191191
constexpr auto BasicClassifier<CharType>::size(T &&value) -> size_type
192192
{
@@ -203,7 +203,7 @@ constexpr auto BasicClassifier<CharType>::size(T &&value) -> size_type
203203
}
204204

205205
//==================================================================================================
206-
template <typename CharType>
206+
template <fly::StandardCharacter CharType>
207207
template <std::size_t N>
208208
constexpr auto BasicClassifier<CharType>::size(const CharType (&value)[N]) -> size_type
209209
{
@@ -212,28 +212,28 @@ constexpr auto BasicClassifier<CharType>::size(const CharType (&value)[N]) -> si
212212
}
213213

214214
//==================================================================================================
215-
template <typename CharType>
215+
template <fly::StandardCharacter CharType>
216216
constexpr bool BasicClassifier<CharType>::is_alpha(CharType ch)
217217
{
218218
return is_upper(unify_az_characters(ch));
219219
}
220220

221221
//==================================================================================================
222-
template <typename CharType>
222+
template <fly::StandardCharacter CharType>
223223
constexpr bool BasicClassifier<CharType>::is_upper(CharType ch)
224224
{
225225
return (ch >= s_upper_a) && (ch <= s_upper_z);
226226
}
227227

228228
//==================================================================================================
229-
template <typename CharType>
229+
template <fly::StandardCharacter CharType>
230230
constexpr bool BasicClassifier<CharType>::is_lower(CharType ch)
231231
{
232232
return (ch >= s_lower_a) && (ch <= s_lower_z);
233233
}
234234

235235
//==================================================================================================
236-
template <typename CharType>
236+
template <fly::StandardCharacter CharType>
237237
constexpr CharType BasicClassifier<CharType>::to_upper(CharType ch)
238238
{
239239
if (is_lower(ch))
@@ -245,7 +245,7 @@ constexpr CharType BasicClassifier<CharType>::to_upper(CharType ch)
245245
}
246246

247247
//==================================================================================================
248-
template <typename CharType>
248+
template <fly::StandardCharacter CharType>
249249
constexpr CharType BasicClassifier<CharType>::to_lower(CharType ch)
250250
{
251251
if (is_upper(ch))
@@ -257,30 +257,30 @@ constexpr CharType BasicClassifier<CharType>::to_lower(CharType ch)
257257
}
258258

259259
//==================================================================================================
260-
template <typename CharType>
260+
template <fly::StandardCharacter CharType>
261261
constexpr bool BasicClassifier<CharType>::is_digit(CharType ch)
262262
{
263263
return (ch ^ s_zero) < 10;
264264
}
265265

266266
//==================================================================================================
267-
template <typename CharType>
267+
template <fly::StandardCharacter CharType>
268268
constexpr bool BasicClassifier<CharType>::is_x_digit(CharType ch)
269269
{
270270
const auto alpha = unify_az_characters(ch);
271271
return is_digit(ch) || ((alpha >= s_upper_a) && (alpha <= s_upper_f));
272272
}
273273

274274
//==================================================================================================
275-
template <typename CharType>
275+
template <fly::StandardCharacter CharType>
276276
constexpr bool BasicClassifier<CharType>::is_space(CharType ch)
277277
{
278278
return (ch == s_space) || (ch == s_form_feed) || (ch == s_line_feed) ||
279279
(ch == s_carriage_return) || (ch == s_horizontal_tab) || (ch == s_vertical_tab);
280280
}
281281

282282
//==================================================================================================
283-
template <typename CharType>
283+
template <fly::StandardCharacter CharType>
284284
constexpr CharType BasicClassifier<CharType>::unify_az_characters(CharType ch)
285285
{
286286
return static_cast<CharType>(static_cast<int_type>(ch) & s_case_mask);

fly/types/string/detail/format_context.hpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "fly/types/string/detail/format_parameters.hpp"
44
#include "fly/types/string/formatters.hpp"
5+
#include "fly/types/string/string_concepts.hpp"
56

67
#include <cstddef>
78
#include <type_traits>
@@ -15,7 +16,7 @@ namespace fly::detail {
1516
* @author Timothy Flynn ([email protected])
1617
* @version April 4, 2021
1718
*/
18-
template <typename OutputIterator, typename CharType>
19+
template <typename OutputIterator, fly::StandardCharacter CharType>
1920
class BasicFormatContext
2021
{
2122
using FormatParameter = BasicFormatParameter<BasicFormatContext>;
@@ -63,7 +64,7 @@ class BasicFormatContext
6364
};
6465

6566
//==================================================================================================
66-
template <typename OutputIterator, typename CharType>
67+
template <typename OutputIterator, fly::StandardCharacter CharType>
6768
template <typename... Parameters>
6869
constexpr BasicFormatContext<OutputIterator, CharType>::BasicFormatContext(
6970
OutputIterator out,
@@ -75,7 +76,7 @@ constexpr BasicFormatContext<OutputIterator, CharType>::BasicFormatContext(
7576
}
7677

7778
//==================================================================================================
78-
template <typename OutputIterator, typename CharType>
79+
template <typename OutputIterator, fly::StandardCharacter CharType>
7980
inline auto BasicFormatContext<OutputIterator, CharType>::arg(std::size_t index) const
8081
-> FormatParameter
8182
{
@@ -88,7 +89,7 @@ inline auto BasicFormatContext<OutputIterator, CharType>::arg(std::size_t index)
8889
}
8990

9091
//==================================================================================================
91-
template <typename OutputIterator, typename CharType>
92+
template <typename OutputIterator, fly::StandardCharacter CharType>
9293
inline OutputIterator &BasicFormatContext<OutputIterator, CharType>::out()
9394
{
9495
return m_out;

fly/types/string/detail/format_parse_context.hpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "fly/types/string/detail/format_parameter_type.hpp"
44
#include "fly/types/string/detail/string_traits.hpp"
55
#include "fly/types/string/lexer.hpp"
6+
#include "fly/types/string/string_concepts.hpp"
67

78
#include <cstddef>
89
#include <string_view>
@@ -16,7 +17,7 @@ namespace fly::detail {
1617
* @author Timothy Flynn ([email protected])
1718
* @version April 25, 2021
1819
*/
19-
template <typename CharType>
20+
template <fly::StandardCharacter CharType>
2021
class BasicFormatParseContext
2122
{
2223
using traits = BasicStringTraits<CharType>;
@@ -115,7 +116,7 @@ class BasicFormatParseContext
115116
};
116117

117118
//==================================================================================================
118-
template <typename CharType>
119+
template <fly::StandardCharacter CharType>
119120
template <std::size_t N>
120121
constexpr BasicFormatParseContext<CharType>::BasicFormatParseContext(
121122
const CharType (&format)[N],
@@ -128,7 +129,7 @@ constexpr BasicFormatParseContext<CharType>::BasicFormatParseContext(
128129
}
129130

130131
//==================================================================================================
131-
template <typename CharType>
132+
template <fly::StandardCharacter CharType>
132133
constexpr std::size_t BasicFormatParseContext<CharType>::next_position()
133134
{
134135
std::size_t position = 0;
@@ -153,7 +154,7 @@ constexpr std::size_t BasicFormatParseContext<CharType>::next_position()
153154
}
154155

155156
//==================================================================================================
156-
template <typename CharType>
157+
template <fly::StandardCharacter CharType>
157158
constexpr std::optional<ParameterType>
158159
BasicFormatParseContext<CharType>::parameter_type(std::size_t position)
159160
{
@@ -167,35 +168,35 @@ BasicFormatParseContext<CharType>::parameter_type(std::size_t position)
167168
}
168169

169170
//==================================================================================================
170-
template <typename CharType>
171+
template <fly::StandardCharacter CharType>
171172
constexpr fly::BasicLexer<CharType> &BasicFormatParseContext<CharType>::lexer()
172173
{
173174
return m_lexer;
174175
}
175176

176177
//==================================================================================================
177-
template <typename CharType>
178+
template <fly::StandardCharacter CharType>
178179
constexpr auto BasicFormatParseContext<CharType>::view() const -> view_type
179180
{
180181
return m_lexer.view();
181182
}
182183

183184
//==================================================================================================
184-
template <typename CharType>
185+
template <fly::StandardCharacter CharType>
185186
void BasicFormatParseContext<CharType>::on_error(const char *error)
186187
{
187188
m_error = error;
188189
}
189190

190191
//==================================================================================================
191-
template <typename CharType>
192+
template <fly::StandardCharacter CharType>
192193
constexpr bool BasicFormatParseContext<CharType>::has_error() const
193194
{
194195
return !m_error.empty();
195196
}
196197

197198
//==================================================================================================
198-
template <typename CharType>
199+
template <fly::StandardCharacter CharType>
199200
std::string BasicFormatParseContext<CharType>::error() const
200201
{
201202
return std::string(m_error.data(), m_error.size());

0 commit comments

Comments
 (0)