| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ae87597 commit da52b09
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -390,6 +390,14 @@ constexpr size_t strsize(const T (&)[N]) { | |||
| 390 | 390 | return N - 1; | |
| 391 | 391 | } | |
| 392 | 392 | ||
| 393 | + // A type that has a valid std::char_traits specialization, as required by | ||
| 394 | + // std::basic_string and std::basic_string_view. | ||
| 395 | + template <typename T> | ||
| 396 | + concept standard_char_type = | ||
| 397 | + std::is_same_v<T, char> || std::is_same_v<T, wchar_t> || | ||
| 398 | + std::is_same_v<T, char8_t> || std::is_same_v<T, char16_t> || | ||
| 399 | + std::is_same_v<T, char32_t>; | ||
| 400 | + | ||
| 393 | 401 | // Allocates an array of member type T. For up to kStackStorageSize items, | |
| 394 | 402 | // the stack is used, otherwise malloc(). | |
| 395 | 403 | template <typename T, size_t kStackStorageSize = 1024> | |
@@ -503,8 +511,12 @@ class MaybeStackBuffer { | |||
| 503 | 511 | free(buf_); | |
| 504 | 512 | } | |
| 505 | 513 | ||
| 506 | - inline std::basic_string<T> ToString() const { return {out(), length()}; } | ||
| 507 | - inline std::basic_string_view<T> ToStringView() const { | ||
| 514 | + template <standard_char_type U = T> | ||
| 515 | + inline std::basic_string<U> ToString() const { | ||
| 516 | + return {out(), length()}; | ||
| 517 | + } | ||
| 518 | + template <standard_char_type U = T> | ||
| 519 | + inline std::basic_string_view<U> ToStringView() const { | ||
| 508 | 520 | return {out(), length()}; | |
| 509 | 521 | } | |
| 510 | 522 | // This can only be used if the buffer contains path data in UTF8 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments