From 44975a016f1ba75718b3f34e97e6e47321f89427 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Tue, 4 Jul 2023 11:07:51 +0200 Subject: [PATCH] mapping: Use member equality operators and document Signed-off-by: Simon Rozman --- include/stdex/mapping.hpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/include/stdex/mapping.hpp b/include/stdex/mapping.hpp index ed6622bc0..47341e91f 100644 --- a/include/stdex/mapping.hpp +++ b/include/stdex/mapping.hpp @@ -18,12 +18,43 @@ namespace stdex T from; // index in source string T to; // index in destination string + /// + /// Constructs a zero to zero mapping + /// inline mapping() : from(0), to(0) {} + + /// + /// Constructs an id mapping + /// + /// \param[in] x Mapping from and to value + /// inline mapping(_In_ T x) : from(x), to(x) {} + + /// + /// Constructs a mapping + /// + /// \param[in] _from Mapping from value + /// \param[in] _to Mapping to value + /// inline mapping(_In_ T _from, _In_ T _to) : from(_from), to(_to) {} - friend bool operator ==(_In_ stdex::mapping const& a, _In_ stdex::mapping const& b) noexcept { return a.from == b.from && a.to == b.to; } - friend bool operator !=(_In_ stdex::mapping const& a, _In_ stdex::mapping const& b) noexcept { return !(a == b); } + /// + /// Are mappings identical? + /// + /// \param[in] other Other mapping to compare against + /// + /// \returns true if mappings are identical or false otherwise + /// + inline bool operator==(const mapping& other) const { return from == other.from && to == other.to; } + + /// + /// Are mappings different? + /// + /// \param[in] other Other mapping to compare against + /// + /// \returns true if mappings are different or false otherwise + /// + inline bool operator!=(const mapping& other) const { return !operator==(other); } }; template >>