mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Closes #315
This commit is contained in:
parent
f01bded2a1
commit
f0935e33b1
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user