Skip to main content

static_assert is a compiler directive. You canIt allows you to check type information at compile time. It will cause a compilation failure and produce an error message that in most IDE's be caught and displayed in the IDE's error window.

static_assert(sizeof(int) == 4,"int should be 4 bytes"); 

assert is for runtime, you can check a variable's value. If the assertion fails then the assertion will trigger. This will cause an error message box that will appear at runtime in some Operating systems (assert implementation dependent)

assert(("mypointer shuoldshould never be null!", mypointer != nullptr)); 

static_assert is a compiler directive. You can check type information at compile time. It will cause a compilation failure and produce an error message that in most IDE's be caught and displayed in the IDE's error window.

static_assert(sizeof(int) == 4,"int should be 4 bytes"); 

assert is for runtime, you can check a variable's value. If the assertion fails then the assertion will trigger. This will cause an error message box that will appear at runtime in some Operating systems (assert implementation dependent)

assert(("mypointer shuold never be null!", mypointer != nullptr)); 

static_assert is a compiler directive. It allows you to check type information at compile time. It will cause a compilation failure and produce an error message that in most IDE's be caught and displayed in the IDE's error window.

static_assert(sizeof(int) == 4,"int should be 4 bytes"); 

assert is for runtime, you can check a variable's value. If the assertion fails then the assertion will trigger. This will cause an error message box that will appear at runtime in some Operating systems (assert implementation dependent)

assert(("mypointer should never be null!", mypointer != nullptr)); 
added 201 characters in body
Source Link
Yochai Timmer
  • 49.6k
  • 25
  • 154
  • 191

static_assert is a compiler directive. youYou can check type information at compile time, and it. It will cause a compilation failure and produce errorsan error message that in most IDE's be caught and displayed in the IDE's error window.

static_assert(sizeof(int) == 4,"int should be 4 bytes"); 

assert is for runtime, you can check a variable's value. If the assertion fails then the assertion will trigger. This will cause an error message box that will appear at runtime in some Operating systems (assert implementation dependent)

assert(("mypointer shuold never be null!", mypointer != nullptr)); 

static_assert is a compiler directive. you can check type information at compile time, and it will produce errors in the error window.

static_assert(sizeof(int) == 4,"int should be 4 bytes"); 

assert is for runtime, you can check a variable's value. If the assertion fails an error message box will appear at runtime

assert(("mypointer shuold never be null!", mypointer != nullptr)); 

static_assert is a compiler directive. You can check type information at compile time. It will cause a compilation failure and produce an error message that in most IDE's be caught and displayed in the IDE's error window.

static_assert(sizeof(int) == 4,"int should be 4 bytes"); 

assert is for runtime, you can check a variable's value. If the assertion fails then the assertion will trigger. This will cause an error message box that will appear at runtime in some Operating systems (assert implementation dependent)

assert(("mypointer shuold never be null!", mypointer != nullptr)); 
Source Link
Yochai Timmer
  • 49.6k
  • 25
  • 154
  • 191

static_assert is a compiler directive. you can check type information at compile time, and it will produce errors in the error window.

static_assert(sizeof(int) == 4,"int should be 4 bytes"); 

assert is for runtime, you can check a variable's value. If the assertion fails an error message box will appear at runtime

assert(("mypointer shuold never be null!", mypointer != nullptr));