mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
🛠 Prevent non-zero default initialization for result types
This commit is contained in:
parent
0a801ee656
commit
323c3ca210
|
@ -39,7 +39,7 @@ namespace sol {
|
|||
load_status err;
|
||||
|
||||
public:
|
||||
load_result() noexcept = default;
|
||||
load_result() noexcept : load_result(nullptr) {}
|
||||
load_result(lua_State* Ls, int stackindex = -1, int retnum = 0, int popnum = 0, load_status lerr = load_status::ok) noexcept
|
||||
: L(Ls), index(stackindex), returncount(retnum), popcount(popnum), err(lerr) {
|
||||
}
|
||||
|
@ -142,8 +142,10 @@ namespace sol {
|
|||
};
|
||||
|
||||
~load_result() {
|
||||
if (L != nullptr) {
|
||||
stack::remove(L, index, popcount);
|
||||
}
|
||||
}
|
||||
};
|
||||
} // namespace sol
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace sol {
|
|||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
protected_function_result() noexcept = default;
|
||||
protected_function_result() noexcept : protected_function_result(nullptr) {}
|
||||
protected_function_result(lua_State* Ls, int idx = -1, int retnum = 0, int popped = 0, call_status pferr = call_status::ok) noexcept
|
||||
: L(Ls), index(idx), returncount(retnum), popcount(popped), err(pferr) {
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace sol {
|
|||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
unsafe_function_result() noexcept = default;
|
||||
unsafe_function_result() noexcept : unsafe_function_result(nullptr) {}
|
||||
unsafe_function_result(lua_State* Ls, int idx = -1, int retnum = 0) noexcept : L(Ls), index(idx), returncount(retnum) {
|
||||
}
|
||||
|
||||
|
@ -158,8 +158,10 @@ namespace sol {
|
|||
returncount = 0;
|
||||
}
|
||||
~unsafe_function_result() {
|
||||
if (L != nullptr) {
|
||||
lua_pop(L, returncount);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
namespace stack {
|
||||
|
|
Loading…
Reference in New Issue
Block a user