if (argc != 2)
throw std::runtime_error("Expect 1 argument. Actual "s + std::to_string(argc - 1));
Don't get terrified by exception. If you don't catch any exception, then it is mostly abort() with dynamic string^ semi-debug in our case means minimal optimisations and debug asserts enabled.
why do you care about the runtime cost of something that makes your program crash ?
I think both parent commenters (htfy96 and Asooka) got on a tangent because htfy96 substituted a throw exception for an assert() in gp's (hermitdev) code -- as if they were equivalent. However, exceptions have fundamentally different semantics from asserts and are not substitutes for each other. (For anyone unfamiliar with the different purposes of exceptions vs asserts, please read the top 2 answers in this Stackoverflow question.[0])
Things like array bounds checking (used as a runtime safety check instead of an "impossibility" check) would not be tested with assert().
To answer your direct question, programmers who use assert() correctly for "testing their understanding of the world by testing an impossible condition" don't want to pay a runtime penalty for it.
[0] https://stackoverflow.com/questions/1467568/debug-assert-vs-...
Let's pretend my previous post started with
"In most cases, "
But to the point about provide a good message: that's on the developer, and its going to be true no matter the language.