| Commit-Queue | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
constexpr std::string_view ExtractFunctionNameViewWithTemplateArgs(This approach seems a bit fragile and error prone
As-is, it doesn't work with `void MyClass<void()>::Method()`
TRACE_EVENT("ui", THIS_FUNCTION_WITH_TEMPLATE_ARGS);I think 2 common patterns that we could add simpler utils for (and might be more flexible)
1- constexpr string concatenation, something like
```
template <size_t N1, size_t N2>
constexpr auto ConcatHelper(std::string_view s1, std::string_view s2) {
std::array<char, N1 - 1 + N2 + 1> result{};
auto it = std::copy(s1.begin(), s1.end(), result.begin()); // No allocation
std::copy(s2.begin(), s2.end(), it);
return result;
}
#define BASE_CONST_STR_CAT(s1, s2)
([&]() {
constexpr std::string_view macro_s1 = (s1);
constexpr std::string_view macro_s2 = (s2);
return ConcatHelper<macro_s1.size(),macro_s2.size()>(macro_s1, macro_s2);
}())
```
2- If plumbing a name from the caller is too difficult, we could add a "T to string" utility, something like (this also relies on parsing PRETTY_FUNCTION, but complexity is bounded because we're always in GetTypeName):
```
template <typename T>
constexpr std::string_view GetTypeName() {
std::string_view name = PRETTY_FUNCTION;
// Clang: "... [T = MyType]"
// GCC: "... [with T = MyType]"
size_t start = name.find("T = ");
if (start == std::string_view::npos) return "Unknown";
start += 4;
size_t end = name.rfind(']');
if (end == std::string_view::npos) return "Unknown";
return name.substr(start, end - start);
}
```
Then we can do something like:
```
TRACE_EVENT("ui", BASE_CONST_STR_CAT("TypedTabHelperAttacher:", GetTypeName<T>()));
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Justin Novosad abandoned this change.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |