Skip to content

Commit

Permalink
gcc buildfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
calro committed Jun 1, 2024
1 parent 2c7d927 commit 8e48456
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions src/util/conversions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ namespace rl::inline utils
struct gd_str_conv
{
explicit constexpr gd_str_conv(TStr&& s)
: m_str{ std::move(s) }
: m_str{ std::forward<TStr>(s) }
{
}

explicit operator godot::String()
requires std::same_as<std::string>
requires std::same_as<TStr, std::string>
{
return godot::String(m_str.c_str());
}

explicit operator godot::String()
requires std::same_as<std::string_view>
requires std::same_as<TStr, std::string_view>
{
return godot::String(m_str.data());
}
Expand Down Expand Up @@ -61,26 +61,11 @@ namespace rl::inline utils
return std::string(in.ascii().ptr());
}

template <>
inline auto to(const godot::String& in) -> std::string_view
{
static_assert(std::is_same_v<godot::String, std::remove_cvref_t<decltype(in)>>);
return std::string_view(in.ascii().ptr());
}

template <>
inline auto to(const godot::StringName& in) -> std::string
{
static_assert(std::is_same_v<godot::StringName, std::remove_cvref_t<decltype(in)>>);
godot::String tmp(in);
return std::string(tmp.ascii().ptr());
}

template <>
inline auto to(const godot::StringName& in) -> std::string_view
{
static_assert(std::is_same_v<godot::StringName, std::remove_cvref_t<decltype(in)>>);
godot::String tmp(in);
return std::string_view(tmp.ascii().ptr());
return std::string(tmp.utf8().ptr());
}
}

0 comments on commit 8e48456

Please sign in to comment.