Fixed ScriptValue::to() for int and float types.

This commit is contained in:
Patrick 2024-11-10 19:08:40 +01:00
parent 017bba89e4
commit 7dcdf2df22

View File

@ -233,7 +233,7 @@ public:
}
else if constexpr (std::is_integral_v<type_t>)
{
return toInt().then([](script_int_t val) { return static_cast<type_t>(val); });
return toInt().then([](script_int_t val) -> Optional<std::decay_t<T>> { return static_cast<type_t>(val); });
}
else if constexpr (std::is_same_v<type_t, script_float_t>)
{
@ -241,7 +241,7 @@ public:
}
else if constexpr (std::is_floating_point_v<type_t>)
{
return toFloat().then([](script_float_t val) { return static_cast<type_t>(val); });
return toFloat().then([](script_float_t val) -> Optional<std::decay_t<T>> { return static_cast<type_t>(val); });
}
else if constexpr (std::is_same_v<type_t, std::string>)
{