C++static_assert

Syntax

  • static_assert( bool_constexpr, message )
  • static_assert( bool_constexpr ) /* Since C++17 */

Parameters

ParameterDetails
bool_constexprExpression to check
messageMessage to print when bool_constexpr is false

Remarks

Unlike runtime assertions, static assertions are checked at compile-time and are also enforced when compiling optimized builds.