Skip to content

Commit cf80eb8

Browse files
committed
fixup! src: avoid C strings in more C++ exception throws
1 parent 5ef9d0b commit cf80eb8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/debug_utils-inl.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,26 @@ concept StringConvertible = requires(T a) {
2323
a.ToString()
2424
} -> std::convertible_to<std::string>;
2525
};
26+
// For std::filesystem::path and similar types
27+
template <typename T>
28+
concept StringConvertibleFSPathLike = requires(T a) {
29+
{
30+
a.string()
31+
} -> std::convertible_to<std::string>;
32+
};
2633

2734
struct ToStringHelper {
2835
template <typename T>
2936
requires(StringConvertible<T>) && (!StringViewConvertible<T>)
3037
static std::string Convert(const T& value) {
3138
return value.ToString();
3239
}
40+
template <typename T>
41+
requires(StringConvertibleFSPathLike<T>) && (!StringViewConvertible<T>) &&
42+
(!StringConvertible<T>)
43+
static std::string Convert(const T& value) {
44+
return value.string();
45+
}
3346
template <typename T>
3447
requires StringViewConvertible<T>
3548
static std::string_view Convert(const T& value) {

0 commit comments

Comments
 (0)