Also, how does it compare to throwing an exception when something goes wrong ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
VERIFY()serves the same purpose asASSERT()(or the standard libraryassert()) – to let you catch things that really shouldn’t ever™ be happening (i.e. a true code bug, something that should be fixed before release). The kinds of things that if for some reason the expression is false, there’s no point to continuing because something is horribly, horribly wrong.This is reflected in the fact that
VERIFY()only stops the program on a false evaluation when compiling in Debug mode – in Release mode, it’s transparent. The difference betweenVERIFY()andASSERT()is thatVERIFY()will still evaluate the expression in Release mode, it simply won’t care about the result – whereasASSERT()is completely removed from the program when compiling in Release mode and thus any side-effects of the expression within it won’t take place.Exceptions are more useful for things that might go wrong, but can be recovered from, since exceptions can be handled by other parts of the program.