Skip to content

Commit dbf6bd6

Browse files
committed
Merge #11071: Use static_assert(…, …) (C++11) instead of assert(…) where appropriate
d1e6f91 Prefer compile-time checking over run-time checking (practicalswift) Pull request description: Use `static_assert(…, …)` instead of `assert(…)` where appropriate. Tree-SHA512: 63b6e50916bcef2195a73f93476bd69657ed9a8eea0bc4382933f478a6df639632c23c076df401fea648142adcb308bb2e6be35cc3dabca30daf7649b790f436
2 parents 4afb5aa + d1e6f91 commit dbf6bd6

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)