diff --git a/src/util.h b/src/util.h index 873a204f9cd794..a56f289b9af802 100644 --- a/src/util.h +++ b/src/util.h @@ -390,6 +390,15 @@ constexpr size_t strsize(const T (&)[N]) { return N - 1; } +// A type that has a valid std::char_traits specialization, as required by +// std::basic_string and std::basic_string_view. +template +concept standard_char_type = std::is_same_v || + std::is_same_v || + std::is_same_v || + std::is_same_v || + std::is_same_v; + // Allocates an array of member type T. For up to kStackStorageSize items, // the stack is used, otherwise malloc(). template @@ -503,8 +512,12 @@ class MaybeStackBuffer { free(buf_); } - inline std::basic_string ToString() const { return {out(), length()}; } - inline std::basic_string_view ToStringView() const { + template + inline std::basic_string ToString() const { + return {out(), length()}; + } + template + inline std::basic_string_view ToStringView() const { return {out(), length()}; } // This can only be used if the buffer contains path data in UTF8