Spaces:
Sleeping
Sleeping
ggml-backend : make path_str compatible with C++20 (llama/12269)
Browse files
ggml/src/ggml-backend-reg.cpp
CHANGED
|
@@ -76,7 +76,14 @@ namespace fs = std::filesystem;
|
|
| 76 |
static std::string path_str(const fs::path & path) {
|
| 77 |
std::string u8path;
|
| 78 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
u8path = path.u8string();
|
|
|
|
| 80 |
} catch (...) {
|
| 81 |
}
|
| 82 |
return u8path;
|
|
|
|
| 76 |
static std::string path_str(const fs::path & path) {
|
| 77 |
std::string u8path;
|
| 78 |
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
|
| 85 |
u8path = path.u8string();
|
| 86 |
+
#endif
|
| 87 |
} catch (...) {
|
| 88 |
}
|
| 89 |
return u8path;
|