diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-05-07 00:22:33 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-05-07 00:22:33 +0100 |
commit | 9cee637a84608fb4a67725fb8c2340c9081146a2 (patch) | |
tree | db5026129fe2162311daad5bd13eeb2cee842e5c | |
parent | Allow implicit conversion to safe<T> (diff) | |
download | netfs-9cee637a84608fb4a67725fb8c2340c9081146a2.tar.bz2 netfs-9cee637a84608fb4a67725fb8c2340c9081146a2.tar.xz netfs-9cee637a84608fb4a67725fb8c2340c9081146a2.zip |
Add additional addition operators to safe for increment/pointers
-rw-r--r-- | netfs/ice/numeric.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/netfs/ice/numeric.h b/netfs/ice/numeric.h index 16af1f4..e47dc27 100644 --- a/netfs/ice/numeric.h +++ b/netfs/ice/numeric.h @@ -83,6 +83,30 @@ operator+(const Left left, const safe<Right> right) template<std::integral Left, std::integral Right> auto +operator+=(Left & left, const safe<Right> right) +{ + return left += static_cast<Left>(right); +} + +template<typename T> +concept pointer = std::is_pointer_v<T>; + +template<pointer Left, std::integral Right> +auto +operator+=(Left & left, const safe<Right> right) +{ + return left += static_cast<Right>(right); +} + +template<pointer Left, std::integral Right> +auto +operator+(const Left left, const safe<Right> right) +{ + return left + static_cast<Right>(right); +} + +template<std::integral Left, std::integral Right> +auto operator+(const safe<Left> left, const Right right) { return static_cast<Right>(left) + right; |