diff options
-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; |