Skip to content

Commit ebcbd04

Browse files
authored
Three-way comparison for CLang 10 fix (Tencent#1679)
C++20 features must enable additional functionality, not to change interface completely
1 parent 2661a17 commit ebcbd04

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

include/rapidjson/document.h

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "encodedstream.h"
2525
#include <new> // placement new
2626
#include <limits>
27-
#ifdef __cpp_impl_three_way_comparison
27+
#ifdef __cpp_lib_three_way_comparison
2828
#include <compare>
2929
#endif
3030

@@ -250,16 +250,15 @@ class GenericMemberIterator {
250250

251251
//! @name relations
252252
//@{
253-
#ifdef __cpp_impl_three_way_comparison
254-
template <bool Const_> bool operator==(const GenericMemberIterator<Const_,Encoding,Allocator>& that) const { return ptr_ == that.ptr_; }
255-
template <bool Const_> std::strong_ordering operator<=>(const GenericMemberIterator<Const_,Encoding,Allocator>& that) const { return ptr_ <=> that.ptr_; }
256-
#else
257-
bool operator==(ConstIterator that) const { return ptr_ == that.ptr_; }
258-
bool operator!=(ConstIterator that) const { return ptr_ != that.ptr_; }
259-
bool operator<=(ConstIterator that) const { return ptr_ <= that.ptr_; }
260-
bool operator>=(ConstIterator that) const { return ptr_ >= that.ptr_; }
261-
bool operator< (ConstIterator that) const { return ptr_ < that.ptr_; }
262-
bool operator> (ConstIterator that) const { return ptr_ > that.ptr_; }
253+
template <bool Const_> bool operator==(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ == that.ptr_; }
254+
template <bool Const_> bool operator!=(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ != that.ptr_; }
255+
template <bool Const_> bool operator<=(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ <= that.ptr_; }
256+
template <bool Const_> bool operator>=(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ >= that.ptr_; }
257+
template <bool Const_> bool operator< (const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ < that.ptr_; }
258+
template <bool Const_> bool operator> (const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ > that.ptr_; }
259+
260+
#ifdef __cpp_lib_three_way_comparison
261+
template <bool Const_> std::strong_ordering operator<=>(const GenericMemberIterator<Const_, Encoding, Allocator>& that) const { return ptr_ <=> that.ptr_; }
263262
#endif
264263
//@}
265264

0 commit comments

Comments
 (0)