Commit c91ace23 authored by Dominik Charousset's avatar Dominik Charousset

Fix comparison operators of intrusive_ptr

parent 35940fa4
......@@ -48,6 +48,8 @@ is based on [Keep a Changelog](https://keepachangelog.com).
malformed output.
- Fix handling of WebSocket frames that are exactly on the 65535 byte limit.
- Fix crash when using a fallback value for optional values (#1427).
- Fix the comparison operator of `intrusive_ptr` to make sure comparing to raw
pointers does not accidentally create a new `intrusive_ptr` instances.
## [0.19.2] - 2023-06-13
......
......@@ -231,27 +231,31 @@ bool operator!=(std::nullptr_t, const intrusive_ptr<T>& x) {
// -- comparison to raw pointer ------------------------------------------------
/// @relates intrusive_ptr
template <class T>
bool operator==(const intrusive_ptr<T>& x, const T* y) {
return x.get() == y;
template <class T, class U>
detail::enable_if_t<detail::is_comparable<T*, U*>::value, bool>
operator==(const intrusive_ptr<T>& lhs, const U* rhs) {
return lhs.get() == rhs;
}
/// @relates intrusive_ptr
template <class T>
bool operator==(const T* x, const intrusive_ptr<T>& y) {
return x == y.get();
template <class T, class U>
detail::enable_if_t<detail::is_comparable<T*, U*>::value, bool>
operator==(const T* lhs, const intrusive_ptr<U>& rhs) {
return lhs == rhs.get();
}
/// @relates intrusive_ptr
template <class T>
bool operator!=(const intrusive_ptr<T>& x, const T* y) {
return x.get() != y;
template <class T, class U>
detail::enable_if_t<detail::is_comparable<T*, U*>::value, bool>
operator!=(const intrusive_ptr<T>& lhs, const U* rhs) {
return lhs.get() != rhs;
}
/// @relates intrusive_ptr
template <class T>
bool operator!=(const T* x, const intrusive_ptr<T>& y) {
return x != y.get();
template <class T, class U>
detail::enable_if_t<detail::is_comparable<T*, U*>::value, bool>
operator!=(const T* lhs, const intrusive_ptr<U>& rhs) {
return lhs != rhs.get();
}
// -- comparison to intrusive_pointer ------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment