I'm learning about pre and post conditions and how to apply them. I am told the Expect/Ensures macros from GSL are the way to go. As far as I understand these macros are supposed to trigger a breakpoint and "lead" you to the origin of the error, however instead of doing this they simply give me a debug error with no really tangible information! Am I doing something wrong here? Thanks!
I'm learning about pre and post conditions and how to apply them.
okay
I am told the Expect/Ensures macros from GSL are the way to go.
er, not sure how this relates to previous statement, but okay...
Edit: never mind; precondition and postcondition (one word, not two) -- something that must always be true before or after a piece of code.
found the public file for gsl_assert from Microsoft's github, which contains definitions for expects/ensures. Made a little project at https://repl.it/@icy_1/QuarterlyOldlaceHypotenuse to play around with it.
As per the comments in gsl/gsl_assert file, the default behavior is simply to terminate, but once the define is in play you get a file and line number. Then it's up to you to automatically breakpoint when uncaught C++ exceptions are thrown. In newer Visual Studio s, it's under Debug->Windows->Exception Settings, and then check off "C++ Exceptions".
btw, I think this would be considered a precondition -- checking the string for emptiness, etc, before doing something with it. For example: