Skip to content

Commit 6fefc05

Browse files
authored
ggml-backend : make path_str compatible with C++20 (#12269)
1 parent 7ab3643 commit 6fefc05

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,3 +1045,4 @@ zrm <[email protected]>
10451045
蕭澧邦 <[email protected]>
10461046
谢乃闻 <[email protected]>
10471047
Нияз Гарифзянов <[email protected]>
1048+
Jason C.H <[email protected]>

ggml/src/ggml-backend-reg.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,14 @@ namespace fs = std::filesystem;
7676
static std::string path_str(const fs::path & path) {
7777
std::string u8path;
7878
try {
79+
#if defined(__cpp_lib_char8_t)
80+
// C++20 and later: u8string() returns std::u8string
81+
std::u8string u8str = path.u8string();
82+
u8path = std::string(reinterpret_cast<const char*>(u8str.c_str()));
83+
#else
84+
// C++17: u8string() returns std::string
7985
u8path = path.u8string();
86+
#endif
8087
} catch (...) {
8188
}
8289
return u8path;

0 commit comments

Comments
 (0)