mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
add default value option to JsonExpectedValue::get
This commit is contained in:
parent
4ec449ed41
commit
908ac44a0b
1 changed files with 2 additions and 2 deletions
|
@ -385,11 +385,11 @@ namespace geode {
|
||||||
// -- Dealing with values --
|
// -- Dealing with values --
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
T get() {
|
T get(T const& defaultValue = T()) {
|
||||||
if (auto v = this->template tryGet<T>()) {
|
if (auto v = this->template tryGet<T>()) {
|
||||||
return *std::move(v);
|
return *std::move(v);
|
||||||
}
|
}
|
||||||
return T();
|
return defaultValue;
|
||||||
}
|
}
|
||||||
template <class T>
|
template <class T>
|
||||||
JsonExpectedValue& into(T& value) {
|
JsonExpectedValue& into(T& value) {
|
||||||
|
|
Loading…
Reference in a new issue