Hacker News new | ask | show | jobs
by CoastalCoder 918 days ago
If I were designing this, I'd want to treat this as an unsupported usage of "find".

If you're okay with using the same error code for (a) string not found and (b) erroneous usage, then returning -1 makes sense.

Since (b) is something that probably indicates a bug in the application code, I'd probably prefer that (b) triggers a different program flow. E.g., raising a C++ exception, failing an `assert`, etc.