#include <iostream>
using namespace std;
// Define a compile-time constant that satisfies static_assert
constexpr int a = 12;
int main() {
// Compile-time validation
static_assert(a == 12, "Failed");
cout << "passed";
return 0;
}
Explanation & Logic Summary:
static_assert checks conditions during compilation, not at runtime.a is incorrect, the program will not compile.a as constexpr ensures its value is known at compile time.a == 12, the static assertion passes and the program prints "passed".Firmware Relevance & Real-World Context:
Embedded systems frequently use static_assert to validate compile-time configuration such as:
This prevents invalid firmware configurations from ever reaching the device, improving reliability and safety.
Expected Output
passed