Merge pull request #57 from grandseiken/main

Make library work on clang on windows
This commit is contained in:
liuzicheng1987
2024-02-07 00:23:07 +08:00
committed by GitHub
3 changed files with 12 additions and 0 deletions
@@ -41,8 +41,12 @@ namespace enums {
template <auto e>
consteval auto get_enum_name_str_view() {
#if defined(__clang__) && defined(_MSC_VER)
const auto func_name = std::string_view{__PRETTY_FUNCTION__};
#else
const auto func_name =
std::string_view{std::source_location::current().function_name()};
#endif
#if defined(__clang__)
const auto split = func_name.substr(0, func_name.size() - 1);
return split.substr(split.find("e = ") + 4);
+4
View File
@@ -43,8 +43,12 @@ constexpr auto wrap(const T& arg) noexcept {
template <class T, auto ptr>
consteval auto get_field_name_str_view() {
#if defined(__clang__) && defined(_MSC_VER)
const auto func_name = std::string_view{__PRETTY_FUNCTION__};
#else
const auto func_name =
std::string_view{std::source_location::current().function_name()};
#endif
#if defined(__clang__)
const auto split = func_name.substr(0, func_name.size() - 2);
return split.substr(split.find_last_of(".") + 1);
+4
View File
@@ -10,8 +10,12 @@ namespace internal {
template <class T>
consteval auto get_type_name_str_view() {
#if defined(__clang__) && defined(_MSC_VER)
const auto func_name = std::string_view{__PRETTY_FUNCTION__};
#else
const auto func_name =
std::string_view{std::source_location::current().function_name()};
#endif
#if defined(__clang__)
const auto split = func_name.substr(0, func_name.size() - 1);
return split.substr(split.find("T = ") + 4);