mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
VC++ is a fuccboi
This commit is contained in:
parent
e97913c97d
commit
938538b491
|
@ -18,6 +18,11 @@ what Sol supports
|
|||
- Implicit conversion to the types you want
|
||||
``double b = table["computed_value"];``
|
||||
|
||||
* :doc:`Optional<api/optional>` support: setting values, getting values of multiple (different) types
|
||||
- :doc:`Lazy evaluation<api/proxy>` for nested/chained queries
|
||||
``optional<int> maybe_number = table["a"]["b"]["invalid_key"];``
|
||||
- Turns on safety when you want it: speed when you don't
|
||||
|
||||
* Support for callables (functions, lambdas, member functions)
|
||||
- Pull out any Lua function with :doc:`sol::function<api/function>`
|
||||
``sol::function fx = table["socket_send"];``
|
||||
|
|
|
@ -31,9 +31,22 @@ struct direct_error_tag {};
|
|||
const auto direct_error = direct_error_tag{};
|
||||
} // detail
|
||||
class error : public std::runtime_error {
|
||||
private:
|
||||
// Because VC++ is a fuccboi
|
||||
std::string w;
|
||||
public:
|
||||
error(const std::string& str): std::runtime_error("lua: error: " + str) {}
|
||||
error(detail::direct_error_tag, const std::string& str) : std::runtime_error(str) {}
|
||||
error(const std::string& str) : error(detail::direct_error, "lua: error: " + str) {}
|
||||
error(detail::direct_error_tag, const std::string& str) : std::runtime_error(""), w(str) {}
|
||||
error(detail::direct_error_tag, std::string&& str) : std::runtime_error(""), w(std::move(str)) {}
|
||||
|
||||
error(const error& e) = default;
|
||||
error(error&& e) = default;
|
||||
error& operator=(const error& e) = default;
|
||||
error& operator=(error&& e) = default;
|
||||
|
||||
virtual const char* what() const override {
|
||||
return w.c_str();
|
||||
}
|
||||
};
|
||||
} // sol
|
||||
|
||||
|
|
|
@ -55,8 +55,9 @@ private:
|
|||
target.push();
|
||||
}
|
||||
}
|
||||
bool valid () const { return stackindex > 0;}
|
||||
~handler() {
|
||||
if (stackindex > 0) {
|
||||
if (valid()) {
|
||||
lua_remove(target.lua_state(), stackindex);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user