C++ Logo

std-proposals

Advanced search

Re: [std-proposals] compile_assert() a static assert that fires at compile time, not runtime.

From: Bjorn Reese <breese_at_[hidden]>
Date: Fri, 20 Feb 2026 12:32:43 +0100
On 2/19/26 15:59, Alejandro Colomar via Std-Proposals wrote:

> A viable GCC implementation would be

Isn't it sufficient and portable to call assert() in a constexpr
context? For example

   constexpr void compiler_assert(bool condition) {
     assert(condition);
   }

I am aware that the above does not generate a useful error message, but
that can be remedied.

Received on 2026-02-20 11:32:51