Fixed some small stuff
This commit is contained in:
parent
9063e17efb
commit
f86c9b522a
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user