Either allow you to specify a default value on failure, or take an optional `bool* success = nullptr` parameter to indicate failure.
Or in C++17, return `std::optional<int>`.
Or in C++17, return `std::optional<int>`.
Furthermore, if you don't check the "success" flag, then your function would fail silently. The exception ensures that something reasonable happens (program termination) when the client does nothing to handle the error.
Exceptions are cleaner.