Skip to content

Commit

Permalink
fix for msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed Jan 15, 2025
1 parent da84890 commit 1f22f39
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions iguana/ylt/reflection/template_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@ constexpr std::string_view get_raw_name() {
template <typename T>
inline constexpr std::string_view type_string() {
constexpr std::string_view sample = get_raw_name<int>();
constexpr size_t pos = sample.find("int");
constexpr size_t prefix_length = sample.find("int");
constexpr std::string_view str = get_raw_name<T>();
constexpr auto next1 = str.rfind(sample[pos + 3]);
constexpr size_t suffix_length = sample.size() - prefix_length - 3;
constexpr auto name =
str.substr(prefix_length, str.size() - prefix_length - suffix_length);
#if defined(_MSC_VER)
constexpr std::size_t npos = str.find_first_of(" ", pos);
if (npos != std::string_view::npos)
return str.substr(npos + 1, next1 - npos - 1);
else
return str.substr(pos, next1 - pos);
#else
return str.substr(pos, next1 - pos);
constexpr size_t space_pos = name.find(" ");
if constexpr (space_pos != std::string_view::npos) {
constexpr auto prefix = name.substr(0, space_pos);
if constexpr (prefix != "const" && prefix != "volatile") {
return name.substr(space_pos + 1);
}
}
#endif
return name;
}

template <auto T>
Expand Down

0 comments on commit 1f22f39

Please sign in to comment.