VC++ is a fuccboi

This commit is contained in:
ThePhD 2016-05-13 13:42:31 -04:00
parent e97913c97d
commit 938538b491
3 changed files with 22 additions and 3 deletions

View File

@ -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"];``

View File

@ -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

View File

@ -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);
}
}