Skip to content

Commit e62493a

Browse files
committed
Fix error converting to double char8_t
1 parent 8cf026f commit e62493a

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

include/simstr/sstring.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class str_algs : public str_src_algs<K, StrRef, Impl, Mutable> {
306306
#ifdef __linux__
307307
if constexpr(sizeof(K) == 1) {
308308
double d{};
309-
if (std::from_chars(ptr, ptr + len, d).ec == std::errc{}) {
309+
if (std::from_chars((const u8s*)ptr, (const u8s*)ptr + len, d).ec == std::errc{}) {
310310
return d;
311311
}
312312
return {};

tests/test_str.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ TEST(SimStr, ToInt) {
484484
TEST(SimStr, to_double) {
485485
EXPECT_EQ(ssa{" 123"}.to_double(), 123.0);
486486
EXPECT_EQ(ssa{" 123.1"}.to_double(), 123.1);
487+
EXPECT_EQ(ssb{u8" 123"}.to_double(), 123.0);
488+
EXPECT_EQ(ssb{u8" 123.1"}.to_double(), 123.1);
487489
EXPECT_EQ(ssu{u" 123.13434"}.to_double(), 123.13434);
488490
EXPECT_EQ(ssuu{U" 123.13434"}.to_double(), 123.13434);
489491
EXPECT_EQ(ssw{L" 123.13434"}.to_double(), 123.13434);

0 commit comments

Comments
 (0)