Skip to content

Commit be6e434

Browse files
author
Hana Dusíková
committed
fix for comparison of utf8_iterator and sentinel
1 parent 6f180c8 commit be6e434

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

include/ctre/utf8.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ struct utf8_iterator {
3636
return lhs.ptr >= lhs.end;
3737
}
3838

39+
constexpr friend bool operator==(sentinel, const utf8_iterator & rhs) {
40+
return rhs.ptr >= rhs.end;
41+
}
42+
3943
constexpr utf8_iterator & operator=(const char8_t * rhs) {
4044
ptr = rhs;
4145
return *this;

single-header/ctre-unicode.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2495,6 +2495,10 @@ struct utf8_iterator {
24952495
return lhs.ptr >= lhs.end;
24962496
}
24972497

2498+
constexpr friend bool operator==(sentinel, const utf8_iterator & rhs) {
2499+
return rhs.ptr >= rhs.end;
2500+
}
2501+
24982502
constexpr utf8_iterator & operator=(const char8_t * rhs) {
24992503
ptr = rhs;
25002504
return *this;
@@ -4217,8 +4221,14 @@ namespace literals {
42174221
#ifdef __INTEL_COMPILER
42184222
// not enable literals
42194223
#elif defined __GNUC__
4220-
#if not(__GNUC__ == 9)
4224+
#if __GNUC__ < 9
42214225
#define CTRE_ENABLE_LITERALS
4226+
#elif __GNUC__ >= 10
4227+
#if !(__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
4228+
// newer versions of GCC will give error when trying to use GNU extension
4229+
#else
4230+
#define CTRE_ENABLE_LITERALS
4231+
#endif
42224232
#endif
42234233
#endif
42244234

single-header/ctre.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2492,6 +2492,10 @@ struct utf8_iterator {
24922492
return lhs.ptr >= lhs.end;
24932493
}
24942494

2495+
constexpr friend bool operator==(sentinel, const utf8_iterator & rhs) {
2496+
return rhs.ptr >= rhs.end;
2497+
}
2498+
24952499
constexpr utf8_iterator & operator=(const char8_t * rhs) {
24962500
ptr = rhs;
24972501
return *this;
@@ -4214,8 +4218,14 @@ namespace literals {
42144218
#ifdef __INTEL_COMPILER
42154219
// not enable literals
42164220
#elif defined __GNUC__
4217-
#if not(__GNUC__ == 9)
4221+
#if __GNUC__ < 9
42184222
#define CTRE_ENABLE_LITERALS
4223+
#elif __GNUC__ >= 10
4224+
#if !(__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
4225+
// newer versions of GCC will give error when trying to use GNU extension
4226+
#else
4227+
#define CTRE_ENABLE_LITERALS
4228+
#endif
42194229
#endif
42204230
#endif
42214231

0 commit comments

Comments
 (0)