Fixed some small stuff

This commit is contained in:
WolverinDEV 2020-04-04 12:22:19 +02:00
parent 9063e17efb
commit f86c9b522a

View File

@ -68,7 +68,13 @@ class variable {
variable&operator=(std::nullptr_t) { r_value() = ""; data->_type = VARTYPE_NULL; return *this;}
template <typename T>
T as() const { return typecast::variable_cast<T>(*this); }
T as() const {
try {
return typecast::variable_cast<T>(*this);
} catch(std::exception& ex) {
throw std::invalid_argument{"failed to parse " + this->r_key() + " as " + typeid(T).name() + " (" + ex.what() + ")"};
}
}
std::string string() const { return as<std::string>(); } //fast
template <typename T> //TODO more secure and not just try and fail