Lecture 6 - Slide 30 : 40
Static assert

static_assert is checked at compile time, whereas assert from <cassert> is checked at run time

If static_assert fails, a compiler error message will appear

p1.cc
Static assert about the size of int.
error-message-p1
Compilation of p1.cpp.
p4.cc
Static asserts abstracted in constexpr function.
p4-compiler-output
Compilation of p4.cpp.
prog1.cpp
An example a static_assert in a template user specialization program.
Go to exercise
Working with static_assert

There is a lot of useful type functions in <type_traits> - see The C++ Prog. Lang. (4. edition) page 1018 - which can be used in static_assert