mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Fix implicit conversion warnings for getter.
This commit is contained in:
parent
6b6efccb66
commit
351c5af8f6
|
@ -92,12 +92,12 @@ template<typename T, typename>
|
||||||
struct getter {
|
struct getter {
|
||||||
template<typename U = T, EnableIf<std::is_floating_point<U>> = 0>
|
template<typename U = T, EnableIf<std::is_floating_point<U>> = 0>
|
||||||
static U get(lua_State* L, int index = -1) {
|
static U get(lua_State* L, int index = -1) {
|
||||||
return lua_tonumber(L, index);
|
return static_cast<U>(lua_tonumber(L, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U = T, EnableIf<std::is_integral<U>, std::is_signed<U>> = 0>
|
template<typename U = T, EnableIf<std::is_integral<U>, std::is_signed<U>> = 0>
|
||||||
static U get(lua_State* L, int index = -1) {
|
static U get(lua_State* L, int index = -1) {
|
||||||
return lua_tounsigned(L, index);
|
return static_cast<U>(lua_tounsigned(L, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U = T, EnableIf<std::is_integral<U>, std::is_unsigned<U>> = 0>
|
template<typename U = T, EnableIf<std::is_integral<U>, std::is_unsigned<U>> = 0>
|
||||||
|
@ -146,7 +146,7 @@ struct getter<std::string> {
|
||||||
static std::string get(lua_State* L, int index = -1) {
|
static std::string get(lua_State* L, int index = -1) {
|
||||||
std::string::size_type len;
|
std::string::size_type len;
|
||||||
auto str = lua_tolstring(L, index, &len);
|
auto str = lua_tolstring(L, index, &len);
|
||||||
return{ str, len };
|
return { str, len };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user