I think this would be better since that is the entire point of std::optional
.
I don't see the point of throwing an exception with std::optional
.
It makes sense to throw an exception if , say, we have:
int i;
try {
db << "SELECT..." >> i{};
}
catch (errors::no_rows& e) {...}
but with std::optional
it'd be better to do this:
std::optional<int> i{};
db << "SELECT..." >> i;
if (not i) {...}