Tuesday, January 5, 2021

Digest for comp.lang.c++@googlegroups.com - 25 updates in 7 topics

Paavo Helde <myfirstname@osa.pri.ee>: Jan 05 11:14AM +0200

05.01.2021 03:23 Lynn McGuire kirjutas:
> "GotW #97: Assertions (Difficulty: 4/10)" by Herb Sutter
 
> https://herbsutter.com/2021/01/01/gotw-97-contracts-part-1-assertions-and-postconditions/
 
> Wow, we do not have any asserts in our 450,000 lines of C++ code.
 
For comparison, we have 7708 asserts in 600,000 lines of C++ code. I
guess this depends on the project type very much.
spudisnotyourbud@grumpysods.com: Jan 05 09:27AM

On Tue, 5 Jan 2021 11:14:29 +0200
 
>> Wow, we do not have any asserts in our 450,000 lines of C++ code.
 
>For comparison, we have 7708 asserts in 600,000 lines of C++ code. I
>guess this depends on the project type very much.
 
Presumably in the production version they're disabled by a build option?
Bonita Montero <Bonita.Montero@gmail.com>: Jan 05 10:58AM +0100

I've got my own assert-/assume-header:
 
#pragma once
#include <cassert>
 
#if !defined(assume)
#if defined(_MSC_VER)
#define assume(e) (__assume(e))
#elif defined(__GNUC__)
#define assume(e) \
{ \
if( !(e) ) \
__builtin_unreachable(); \
}
#else
#define assume(e) ((void)0)

No comments: