Comment by Zambyte
One option is to use asserts that are only included in debug builds. That way any incorrect call of the function will crash the program in debug builds, but will have the performance benefits of the lifted conditional checks in release builds.
You'll end up duplicating the condition, but that seems like a reasonable price to pay for correct and performant software.