From 6255307743dc0aafb19e3921c59c156b1c507633 Mon Sep 17 00:00:00 2001 From: Joseph Walton-Rivers <joseph@walton-rivers.uk> Date: Fri, 2 Sep 2022 02:48:38 +0100 Subject: [PATCH] document type-safe wrapper --- include/fggl/util/safety.hpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/include/fggl/util/safety.hpp b/include/fggl/util/safety.hpp index 1daf295..cd5719a 100644 --- a/include/fggl/util/safety.hpp +++ b/include/fggl/util/safety.hpp @@ -49,12 +49,30 @@ namespace fggl::util { constexpr explicit operator std::string_view() const { return m_value; } + /** + * Check for equality of two handles. + * + * Two values are considered the same of the values contained inside them are considered equal, and both + * types share the same tagging interface. + * + * @param other the value being compared against. + * @return true iff the contained values are equal + */ bool operator==(const OpaqueName<T, Tag> &other) const { return m_value == other.m_value; } + /** + * Check for equality of two handles. + * + * Two values are considered the same of the values contained inside them are considered equal, and both + * types share the same tagging interface. + * + * @param other the value being compared against. + * @return true iff the contained values are not equal + */ bool operator!=(const OpaqueName<T, Tag> &other) const { - return !(*this == other); + return m_value != other.m_value; } bool operator<(const OpaqueName<T, Tag> &other) const { @@ -65,6 +83,9 @@ namespace fggl::util { return m_value <=> other.m_value; } + /** + * Generate a new tagged instance of a handle. + */ constexpr static OpaqueName<T, Tag> make(T value) { return OpaqueName<T, Tag>(value); } -- GitLab