This commit is contained in:
hsutter 2017-07-24 11:52:25 -07:00
parent f01bded2a1
commit f0935e33b1

View File

@ -680,11 +680,13 @@ You don't need to write error handlers for errors caught at compile time.
if (bits < 32)
cerr << "Int too small\n"
This example is easily simplified
This example fails to achieve what it is trying to achieve (because overflow is undefined) and should be replaced with a simple `static_assert`:
// Int is an alias used for integers
static_assert(sizeof(Int) >= 4); // do: compile-time check
Or better still just use the type system and replace `Int` with `int32_t`.
##### Example
void read(int* p, int n); // read max n integers into *p