cpp_weekly icon indicating copy to clipboard operation
cpp_weekly copied to clipboard

Can a function that uses "assert(...)" be marked noexcept? Should it be?

Open calebarist opened this issue 2 years ago • 4 comments

Channel

Is this a "C++Weekly" or "The [Fill in the Blank] Programmer" episode request?

Your choice, could event just be a tid-bit.

Topics

What topics are important to cover for this episode?

assert() under the hood?

Length

Should this be bite-sized (5-10 minutes) or more long form (10-20 minutes)?

calebarist avatar Sep 11 '23 19:09 calebarist

I like this idea.

sakgoyal avatar Jun 19 '24 22:06 sakgoyal

https://en.cppreference.com/w/cpp/header/cassert

lefticus avatar Mar 07 '25 21:03 lefticus

The Lakos principle says that any function that is has preconditions of any sort should not be noexcept, so there's some conversation to have here.

lefticus avatar Apr 21 '25 15:04 lefticus

Destructors have no preconditions and are noexcept by default, does this mean we shouldn't assert in them to catch mistakes at more opportune times?

LB-- avatar Apr 21 '25 23:04 LB--