diff --git a/olp-cpp-sdk-core/include/olp/core/client/CancellationContext.h b/olp-cpp-sdk-core/include/olp/core/client/CancellationContext.h index fbefe2979..1968730b4 100644 --- a/olp-cpp-sdk-core/include/olp/core/client/CancellationContext.h +++ b/olp-cpp-sdk-core/include/olp/core/client/CancellationContext.h @@ -83,6 +83,7 @@ class CORE_API CancellationContext { private: /// A helper for unordered containers. friend struct CancellationContextHash; + friend struct CancellationContextEquality; /** * @brief An implementation used to shared the `CancellationContext` instance. @@ -126,6 +127,22 @@ struct CORE_API CancellationContextHash { size_t operator()(const CancellationContext& context) const; }; +/** + * @brief A helper for unordered containers for equality comparison + */ +struct CORE_API CancellationContextEquality { + /** + * @brief Checks equality for two `CancellationContext` instances. + * + * @param lhs The first `CancellationContext` instance. + * @param rhs The second `CancellationContext` instance. + * + * @return True if both refer to the same implementation; false otherwise. + */ + bool operator()(const CancellationContext& lhs, + const CancellationContext& rhs) const; +}; + } // namespace client } // namespace olp diff --git a/olp-cpp-sdk-core/include/olp/core/client/CancellationContext.inl b/olp-cpp-sdk-core/include/olp/core/client/CancellationContext.inl index e19aeefb2..2d58fc903 100644 --- a/olp-cpp-sdk-core/include/olp/core/client/CancellationContext.inl +++ b/olp-cpp-sdk-core/include/olp/core/client/CancellationContext.inl @@ -79,5 +79,10 @@ inline size_t CancellationContextHash::operator()( context.impl_); } +inline bool CancellationContextEquality::operator()( + const CancellationContext& lhs, const CancellationContext& rhs) const { + return lhs.impl_ == rhs.impl_; +} + } // namespace client } // namespace olp