Stats

94 Contributors: 6 Thursday, June 1, 2017
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

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.

Related Examples