Merge pull request #38 from LeonineKing1199/ambiguous-reversed-operator

Ambiguous reversed operator fixes
This commit is contained in:
Peter Dimov
2021-11-19 04:25:45 +02:00
committed by GitHub
4 changed files with 11 additions and 7 deletions

View File

@ -827,13 +827,13 @@ namespace boost {
T* operator->() { return value_.value_ptr(); }
T const* operator->() const { return value_.value_ptr(); }
bool operator==(optional<T> const& x)
bool operator==(optional<T> const& x) const
{
return has_value_ ? x.has_value_ && value_.value() == x.value_.value()
: !x.has_value_;
}
bool operator!=(optional<T> const& x) { return !((*this) == x); }
bool operator!=(optional<T> const& x) const { return !((*this) == x); }
void swap(optional<T>& x)
{

View File

@ -113,6 +113,10 @@ namespace test {
ptr_ = ptr_->next_;
return tmp;
}
bool operator==(list_iterator y) const { return ptr_ == y.ptr_; }
bool operator!=(list_iterator y) const { return ptr_ != y.ptr_; }
bool operator==(const_iterator y) const { return ptr_ == y.ptr_; }
bool operator!=(const_iterator y) const { return ptr_ != y.ptr_; }
};

View File

@ -65,9 +65,9 @@
{ \
return (std::numeric_limits<size_type>::max)(); \
} \
bool operator==(name<T> const&) { return true; } \
bool operator!=(name<T> const&) { return false; } \
/**/
bool operator==(name<T> const&) const { return true; } \
bool operator!=(name<T> const&) const { return false; } \
/**/
struct yes_type
{

View File

@ -30,8 +30,8 @@ template <typename T> struct test_allocator
template <typename T2> test_allocator(test_allocator<T2> const&) {}
T* allocate(std::size_t n) const { return (T*)malloc(sizeof(T) * n); }
void deallocate(T* ptr, std::size_t) const { free(ptr); }
bool operator==(test_allocator const&) { return true; }
bool operator!=(test_allocator const&) { return false; }
bool operator==(test_allocator const&) const { return true; }
bool operator!=(test_allocator const&) const { return false; }
};
#endif