Skip to content

Commit

Permalink
Three-way comparison for CLang 10 fix (Tencent#1679)
Browse files Browse the repository at this point in the history
C++20 features must enable additional functionality, not to change interface completely
  • Loading branch information
kolya7k authored and jasonsandlin committed Aug 2, 2023
1 parent 01cbc9f commit 3a67b06
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions include/rapidjson/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "encodedstream.h"
#include <new> // placement new
#include <limits>
#ifdef __cpp_impl_three_way_comparison
#ifdef __cpp_lib_three_way_comparison
#include <compare>
#endif

Expand Down Expand Up @@ -177,16 +177,15 @@ class GenericMemberIterator {

//! @name relations
//@{
#ifdef __cpp_impl_three_way_comparison
template <bool Const_> bool operator==(const GenericMemberIterator<Const_,Encoding,Allocator>& that) const { return ptr_ == that.ptr_; }
template <bool Const_> std::strong_ordering operator<=>(const GenericMemberIterator<Const_,Encoding,Allocator>& that) const { return ptr_ <=> that.ptr_; }
#else
bool operator==(ConstIterator that) const { return ptr_ == that.ptr_; }
bool operator!=(ConstIterator that) const { return ptr_ != that.ptr_; }
bool operator<=(ConstIterator that) const { return ptr_ <= that.ptr_; }
bool operator>=(ConstIterator that) const { return ptr_ >= that.ptr_; }
bool operator< (ConstIterator that) const { return ptr_ < that.ptr_; }
bool operator> (ConstIterator that) const { return ptr_ > that.ptr_; }
template <bool Const_> bool operator==(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ == that.ptr_; }
template <bool Const_> bool operator!=(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ != that.ptr_; }
template <bool Const_> bool operator<=(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ <= that.ptr_; }
template <bool Const_> bool operator>=(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ >= that.ptr_; }
template <bool Const_> bool operator< (const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ < that.ptr_; }
template <bool Const_> bool operator> (const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ > that.ptr_; }

#ifdef __cpp_lib_three_way_comparison
template <bool Const_> std::strong_ordering operator<=>(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ <=> that.ptr_; }
#endif
//@}

Expand Down

0 comments on commit 3a67b06

Please sign in to comment.