File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -32,24 +32,18 @@ class CharacterConverter {
3232 bool isEmpty ();
3333 bool isValidState ();
3434
35- template <typename CharType> size_t sizeAs () {
36- if constexpr (cpp::is_same_v<CharType, char8_t >)
37- return state->total_bytes ;
38- else // char32_t
39- return 1 ; // every character fits in a single char32_t
40- }
35+ template <typename CharType> size_t sizeAs ();
36+ template <> size_t sizeAs<char8_t >() { return state->total_bytes ; }
37+ template <> size_t sizeAs<char32_t >() { return 1 ; }
4138
4239 int push (char8_t utf8_byte);
4340 int push (char32_t utf32);
4441
4542 ErrorOr<char8_t > pop_utf8 ();
4643 ErrorOr<char32_t > pop_utf32 ();
47- template <typename CharType> ErrorOr<CharType> pop () {
48- if constexpr (cpp::is_same_v<CharType, char8_t >)
49- return pop_utf8 ();
50- else
51- return pop_utf32 ();
52- }
44+ template <typename CharType> ErrorOr<CharType> pop ();
45+ template <> ErrorOr<char8_t > pop () { return pop_utf8 (); }
46+ template <> ErrorOr<char32_t > pop () { return pop_utf32 (); }
5347};
5448
5549} // namespace internal
You can’t perform that action at this time.
0 commit comments