Skip to content

Commit

Permalink
Merge #11071: Use static_assert(…, …) (C++11) instead of assert(…) wh…
Browse files Browse the repository at this point in the history
…ere 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
  • Loading branch information
laanwj committed Aug 18, 2017
2 parents 4afb5aa + d1e6f91 commit dbf6bd6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/developer-notes.md
Expand Up @@ -37,6 +37,7 @@ code.

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

Block style example:
```c++
Expand Down
2 changes: 1 addition & 1 deletion src/arith_uint256.h
Expand Up @@ -250,7 +250,7 @@ class base_uint

uint64_t GetLow64() const
{
assert(WIDTH >= 2);
static_assert(WIDTH >= 2, "Assertion WIDTH >= 2 failed (WIDTH = BITS / 32). BITS is a template parameter.");
return pn[0] | (uint64_t)pn[1] << 32;
}
};
Expand Down

0 comments on commit dbf6bd6

Please sign in to comment.