Skip to content

Commit d1e6f91

Browse files
Prefer compile-time checking over run-time checking
1 parent 22e301a commit d1e6f91

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

doc/developer-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ code.
3737

3838
- **Miscellaneous**
3939
- `++i` is preferred over `i++`.
40+
- `static_assert` is preferred over `assert` where possible. Generally; compile-time checking is preferred over run-time checking.
4041

4142
Block style example:
4243
```c++

src/arith_uint256.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class base_uint
250250

251251
uint64_t GetLow64() const
252252
{
253-
assert(WIDTH >= 2);
253+
static_assert(WIDTH >= 2, "Assertion WIDTH >= 2 failed (WIDTH = BITS / 32). BITS is a template parameter.");
254254
return pn[0] | (uint64_t)pn[1] << 32;
255255
}
256256
};

0 commit comments

Comments
 (0)