Age | Commit message (Collapse) | Author |
|
Problem:
- `constexpr` functions are decorated with the `inline` specifier
keyword. This is redundant because `constexpr` functions are
implicitly `inline`.
- [dcl.constexpr], ยง7.1.5/2 in the C++11 standard): "constexpr
functions and constexpr constructors are implicitly inline (7.1.2)".
Solution:
- Remove the redundant `inline` keyword.
|
|
Problem:
- `Checked` is not `constexpr`-aware.
Solution:
- Decorate member functions with `constexpr` keyword.
- Add tests to ensure the functionality where possible.
|
|
Problem:
- Compiler-generated functions are being defined which results in
extra code to maintain.
Solution:
- Switch to compiler-generated default functions for default
construction, copy assignment, move assignment, copy construction
and move construction.
|
|
Specifically:
- post-increment actually implemented pre-increment
- helper-templates that provided operator{+,-,*,/}() couldn't possibly work,
because the interface of add (etc) were incompatible (not taking a Checked<>,
and returning void)
|
|
Once again, we need to hint the compiler that it should inline the function, and
then it is able to eliminate the assertion.
|
|
The two-argument version doesn't need an extra template parameter.
|
|
Apparently Clang does not have __builtin_foo_overflow_p()
Fixes #2044.
|
|
And switch the two-argument version of Checked::multiplication_would_overflow()
to use __builtin_mul_overflow_p(). This helps GCC optimize the code better.
|
|
This allows you to comfortably test if multiply 2 or 3 values would
cause arithmetic overflow.
|
|
A Checked<T> is a boxed integer type that asserts if you try to use its
value after an arithmetic overflow.
|