pycapnp/capnp/helpers/fixMaybe.h
Jason Paryani 3d8dc6daa9 Change which method to be a property and return an enum type.
Old code using which() will still work since the enum type has a
__call__ method.
2014-02-13 19:24:06 -08:00

11 lines
220 B
C++

#include "kj/common.h"
#include <stdexcept>
template<typename T>
T fixMaybe(::kj::Maybe<T> val) {
KJ_IF_MAYBE(new_val, val) {
return *new_val;
} else {
throw std::invalid_argument("Member was null.");
}
}