sqlite_modern_cpp icon indicating copy to clipboard operation
sqlite_modern_cpp copied to clipboard

Set `std::optional` to `std::nullopt` instead of throwing `sqlite::errors::no_rows`

Open ghost opened this issue 2 years ago • 0 comments

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) {...}

ghost avatar May 06 '23 02:05 ghost