Hacker News new | ask | show | jobs
by boomer_joe 2035 days ago
What is the advantage of your assume macro over regular C11 static_assert / assert? Apologies if it is immediately obvious.

And in case anyone else is wondering, the advantage of that m_max macro is that it evaluates each of its arguments only once.

1 comments

The types of things that _Static_assert takes is substantially more limited than this construct, as it can only take an "integral constant expression" which is in practice basic integer arithmetic and nothing else. This construct works with more complicated things that are nonetheless known at compile time, such as "asdf"[4] (should be 0).