3 ms·
I think there's something to be said about them running automatically that is lost when you say they're just asserts.
by jayd16 1y ago
I think there's something to be said about them running automatically that is lost when you say they're just asserts.
- almostgotcaught 1y agoi don't get it - if do int foo(int a) { assert(a > 5); int b = a * 10; assert(b > 50); return b; } do you think those asserts don't "run automatically"?
- gblargg 1y agoYou define the invariants once for the class and they are run around every public function. Done manually you'd probably use a helper object that calls the invariants in its constructor and destructor (have to handle exceptions) that you have to add to every public function's definition.