Skip to content

Commit 6801b0c

Browse files
authored
Merge pull request #289 from dalle/issue288-char8-support
Support char8_t on C++20
2 parents 65911af + d3f7113 commit 6801b0c

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ int main() {
149149
std::cerr << "parsing failure\n";
150150
return EXIT_FAILURE;
151151
}
152-
std::cout << "parsed the number "<< i << std::endl;
152+
std::cout << "parsed the number " << i << std::endl;
153153
154154
std::string binstr = "1001111000011001110110111001001010110100111000110001100";
155155
@@ -158,7 +158,7 @@ int main() {
158158
std::cerr << "parsing failure\n";
159159
return EXIT_FAILURE;
160160
}
161-
std::cout << "parsed the number "<< i << std::endl;
161+
std::cout << "parsed the number " << i << std::endl;
162162
163163
std::string hexstr = "4f0cedc95a718c";
164164
@@ -167,7 +167,7 @@ int main() {
167167
std::cerr << "parsing failure\n";
168168
return EXIT_FAILURE;
169169
}
170-
std::cout << "parsed the number "<< i << std::endl;
170+
std::cout << "parsed the number " << i << std::endl;
171171
return EXIT_SUCCESS;
172172
}
173173
```

include/fast_float/float_common.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,12 @@ struct is_supported_char_type
237237
: std::integral_constant<bool, std::is_same<UC, char>::value ||
238238
std::is_same<UC, wchar_t>::value ||
239239
std::is_same<UC, char16_t>::value ||
240-
std::is_same<UC, char32_t>::value> {};
240+
std::is_same<UC, char32_t>::value
241+
#ifdef __cpp_char8_t
242+
|| std::is_same<UC, char8_t>::value
243+
#endif
244+
> {
245+
};
241246

242247
// Compares two ASCII strings in a case insensitive manner.
243248
template <typename UC>
@@ -748,6 +753,11 @@ template <> constexpr char16_t const *str_const_nan<char16_t>() {
748753
template <> constexpr char32_t const *str_const_nan<char32_t>() {
749754
return U"nan";
750755
}
756+
#ifdef __cpp_char8_t
757+
template <> constexpr char8_t const *str_const_nan<char8_t>() {
758+
return u8"nan";
759+
}
760+
#endif
751761

752762
template <typename UC> constexpr UC const *str_const_inf();
753763
template <> constexpr char const *str_const_inf<char>() { return "infinity"; }
@@ -760,6 +770,11 @@ template <> constexpr char16_t const *str_const_inf<char16_t>() {
760770
template <> constexpr char32_t const *str_const_inf<char32_t>() {
761771
return U"infinity";
762772
}
773+
#ifdef __cpp_char8_t
774+
template <> constexpr char8_t const *str_const_inf<char8_t>() {
775+
return u8"infinity";
776+
}
777+
#endif
763778

764779
template <typename = void> struct int_luts {
765780
static constexpr uint8_t chdigit[] = {

0 commit comments

Comments
 (0)