Skip to content

Allow CancellationContext in hashes #1612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions olp-cpp-sdk-core/include/olp/core/client/CancellationContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading