From 4a8ba9eb60ca51da6154190f30b63619b7db9d4a Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 24 Jan 2024 12:26:54 +0100 Subject: [PATCH] mapping: add + operator This allows cleaner arithmetic when adjusting mapping by an offset. Signed-off-by: Simon Rozman --- include/stdex/mapping.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/stdex/mapping.hpp b/include/stdex/mapping.hpp index 3d5164f03..048f17c65 100644 --- a/include/stdex/mapping.hpp +++ b/include/stdex/mapping.hpp @@ -55,6 +55,18 @@ namespace stdex /// \returns true if mappings are different or false otherwise /// bool operator!=(const mapping& other) const { return !operator==(other); } + + /// + /// Adds two mappings by components + /// + /// \param[in] other Second mapping + /// + /// \returns Resulting mapping + /// + mapping operator+(_In_ const mapping& other) const + { + return mapping(from + other.from, to + other.to); + } }; template >>