I\'ve been studying OpenCV tutorials and came across the assert function; what does it do?
C++11 N3337 standard draft
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf
19.3 Assertions
1 The header
, described in (Table 42), provides a macro for documenting C ++ program assertions and a mechanism for disabling the assertion checks. 2 The contents are the same as the Standard C library header
.
C99 N1256 standard draft
http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1256.pdf
7.2 Diagnostics
1 The header
defines the assert macro and refers to another macro,NDEBUGwhich is not defined by. IfNDEBUGis defined as a macro name at the point in the source file whereis included, the assert macro is defined simply as #define assert(ignore) ((void)0)The assert macro is redefined according to the current state of NDEBUG each time that
is included.2. The assert macro shall be implemented as a macro, not as an actual function. If the macro definition is suppressed in order to access an actual function, the behavior is undefined.
7.2.1 Program diagnostics
7.2.1.1 The assert macro
Synopsis
1.
#includevoid assert(scalar expression); Description
2 The assert macro puts diagnostic tests into programs; it expands to a void expression. When it is executed, if expression (which shall have a scalar type) is false (that is, compares equal to 0), the assert macro writes information about the particular call that failed (including the text of the argument, the name of the source file, the source line number, and the name of the enclosing function — the latter are respectively the values of the preprocessing macros
__FILE__and__LINE__and of the identifier__func__) on the standard error stream in an implementation-defined format. 165) It then calls the abort function.Returns
3 The assert macro returns no value.