We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1196475 commit fc46ac3Copy full SHA for fc46ac3
include/plg/enum.hpp
@@ -28,17 +28,16 @@ namespace plg {
28
std::array<char, N + 1> content_{};
29
};
30
31
- constexpr auto is_pretty(char ch) noexcept {
32
- return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
33
- }
34
-
35
constexpr auto pretty_name(std::string_view sv) noexcept {
36
- for (std::size_t n = sv.size() - 1; n > 0; --n) {
37
- if (!is_pretty(sv[n])) {
38
- sv.remove_prefix(n + 1);
39
- break;
40
+ // Find last non-pretty character from the end
+ auto pos = sv.find_last_not_of(
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"
+ );
+
+ if (pos != std::string_view::npos) {
+ sv.remove_prefix(pos + 1);
41
}
42
return sv;
43
44
0 commit comments