Skip to content

Commit 30c00c1

Browse files
committed
small update if detection of mirrored comparisons
1 parent 59aeaab commit 30c00c1

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

include/ctre/utf8.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#define CTRE_ENABLE_UTF8_RANGE
1414
#endif
1515

16+
#if defined(__cpp_impl_three_way_comparison) && (__cpp_impl_three_way_comparison >= 201907L)
17+
#define CTRE_NO_NEED_FOR_ADDITIONAL_COMPARISONS
18+
#endif
19+
1620
namespace ctre {
1721

1822
struct utf8_iterator {
@@ -43,7 +47,7 @@ struct utf8_iterator {
4347
friend constexpr auto operator==(self_type, const char8_t * other_ptr) noexcept {
4448
return *other_ptr == char8_t{0};
4549
}
46-
#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L
50+
#ifndef CTRE_NO_NEED_FOR_ADDITIONAL_COMPARISONS
4751
friend constexpr auto operator!=(self_type, const char8_t * other_ptr) noexcept {
4852
return *other_ptr != char8_t{0};
4953
}
@@ -60,7 +64,7 @@ struct utf8_iterator {
6064

6165
const char8_t * ptr{nullptr};
6266
const char8_t * end{nullptr};
63-
#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L
67+
#ifndef CTRE_NO_NEED_FOR_ADDITIONAL_COMPARISONS
6468
constexpr friend bool operator!=(const utf8_iterator & lhs, sentinel) {
6569
return lhs.ptr < lhs.end;
6670
}
@@ -85,7 +89,7 @@ struct utf8_iterator {
8589
return lhs.ptr == rhs.ptr;
8690
}
8791

88-
#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L
92+
#ifndef CTRE_NO_NEED_FOR_ADDITIONAL_COMPARISONS
8993
constexpr friend bool operator!=(sentinel, const utf8_iterator & rhs) {
9094
return rhs.ptr < rhs.end;
9195
}

single-header/ctre-unicode.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3106,6 +3106,10 @@ constexpr bool starts_with_anchor(const flags & f, ctll::list<capture_with_name<
31063106
#define CTRE_ENABLE_UTF8_RANGE
31073107
#endif
31083108

3109+
#if defined(__cpp_impl_three_way_comparison) && (__cpp_impl_three_way_comparison >= 201907L)
3110+
#define CTRE_NO_NEED_FOR_ADDITIONAL_COMPARISONS
3111+
#endif
3112+
31093113
namespace ctre {
31103114

31113115
struct utf8_iterator {
@@ -3136,7 +3140,7 @@ struct utf8_iterator {
31363140
friend constexpr auto operator==(self_type, const char8_t * other_ptr) noexcept {
31373141
return *other_ptr == char8_t{0};
31383142
}
3139-
#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L
3143+
#ifndef CTRE_NO_NEED_FOR_ADDITIONAL_COMPARISONS
31403144
friend constexpr auto operator!=(self_type, const char8_t * other_ptr) noexcept {
31413145
return *other_ptr != char8_t{0};
31423146
}
@@ -3153,7 +3157,7 @@ struct utf8_iterator {
31533157

31543158
const char8_t * ptr{nullptr};
31553159
const char8_t * end{nullptr};
3156-
#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L
3160+
#ifndef CTRE_NO_NEED_FOR_ADDITIONAL_COMPARISONS
31573161
constexpr friend bool operator!=(const utf8_iterator & lhs, sentinel) {
31583162
return lhs.ptr < lhs.end;
31593163
}
@@ -3178,7 +3182,7 @@ struct utf8_iterator {
31783182
return lhs.ptr == rhs.ptr;
31793183
}
31803184

3181-
#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L
3185+
#ifndef CTRE_NO_NEED_FOR_ADDITIONAL_COMPARISONS
31823186
constexpr friend bool operator!=(sentinel, const utf8_iterator & rhs) {
31833187
return rhs.ptr < rhs.end;
31843188
}

single-header/ctre.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,6 +3103,10 @@ constexpr bool starts_with_anchor(const flags & f, ctll::list<capture_with_name<
31033103
#define CTRE_ENABLE_UTF8_RANGE
31043104
#endif
31053105

3106+
#if defined(__cpp_impl_three_way_comparison) && (__cpp_impl_three_way_comparison >= 201907L)
3107+
#define CTRE_NO_NEED_FOR_ADDITIONAL_COMPARISONS
3108+
#endif
3109+
31063110
namespace ctre {
31073111

31083112
struct utf8_iterator {
@@ -3133,7 +3137,7 @@ struct utf8_iterator {
31333137
friend constexpr auto operator==(self_type, const char8_t * other_ptr) noexcept {
31343138
return *other_ptr == char8_t{0};
31353139
}
3136-
#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L
3140+
#ifndef CTRE_NO_NEED_FOR_ADDITIONAL_COMPARISONS
31373141
friend constexpr auto operator!=(self_type, const char8_t * other_ptr) noexcept {
31383142
return *other_ptr != char8_t{0};
31393143
}
@@ -3150,7 +3154,7 @@ struct utf8_iterator {
31503154

31513155
const char8_t * ptr{nullptr};
31523156
const char8_t * end{nullptr};
3153-
#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L
3157+
#ifndef CTRE_NO_NEED_FOR_ADDITIONAL_COMPARISONS
31543158
constexpr friend bool operator!=(const utf8_iterator & lhs, sentinel) {
31553159
return lhs.ptr < lhs.end;
31563160
}
@@ -3175,7 +3179,7 @@ struct utf8_iterator {
31753179
return lhs.ptr == rhs.ptr;
31763180
}
31773181

3178-
#if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L
3182+
#ifndef CTRE_NO_NEED_FOR_ADDITIONAL_COMPARISONS
31793183
constexpr friend bool operator!=(sentinel, const utf8_iterator & rhs) {
31803184
return rhs.ptr < rhs.end;
31813185
}

0 commit comments

Comments
 (0)