Skip to content

Commit 903f8cc

Browse files
authored
Merge pull request #264 from jcelerier/patch-1
Fix building of utf8.hpp on clang-10 / libstdc++-8
2 parents b5c0f7b + a4faab8 commit 903f8cc

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

include/ctre/utf8.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#include <string_view>
88
#include <iterator>
99

10+
#if __cpp_lib_char8_t >= 201811L
11+
#define CTRE_ENABLE_UTF8_RANGE
12+
#endif
13+
1014
namespace ctre {
1115

1216
struct utf8_iterator {
@@ -188,6 +192,7 @@ struct utf8_iterator {
188192
}
189193
};
190194

195+
#ifdef CTRE_ENABLE_UTF8_RANGE
191196
struct utf8_range {
192197
std::u8string_view range;
193198
constexpr utf8_range(std::u8string_view r) noexcept: range{r} { }
@@ -199,9 +204,10 @@ struct utf8_range {
199204
return utf8_iterator::sentinel{};
200205
}
201206
};
207+
#endif
202208

203209
}
204210

205211
#endif
206212

207-
#endif
213+
#endif

include/ctre/wrapper.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ template <typename RE, typename Method, typename Modifier> struct regular_expres
184184
static constexpr CTRE_FORCE_INLINE auto exec(std::wstring_view sv) noexcept {
185185
return exec(sv.begin(), sv.end());
186186
}
187-
#if __cpp_char8_t >= 201811
187+
#ifdef CTRE_ENABLE_UTF8_RANGE
188188
static constexpr CTRE_FORCE_INLINE auto exec(std::u8string_view sv) noexcept {
189189
return exec_with_result_iterator<const char8_t *>(utf8_range(sv).begin(), utf8_range(sv).end());
190190
}

single-header/ctre-unicode.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3031,6 +3031,10 @@ constexpr bool starts_with_anchor(const flags & f, ctll::list<capture_with_name<
30313031
#include <string_view>
30323032
#include <iterator>
30333033

3034+
#if __cpp_lib_char8_t >= 201811L
3035+
#define CTRE_ENABLE_UTF8_RANGE
3036+
#endif
3037+
30343038
namespace ctre {
30353039

30363040
struct utf8_iterator {
@@ -3212,6 +3216,7 @@ struct utf8_iterator {
32123216
}
32133217
};
32143218

3219+
#ifdef CTRE_ENABLE_UTF8_RANGE
32153220
struct utf8_range {
32163221
std::u8string_view range;
32173222
constexpr utf8_range(std::u8string_view r) noexcept: range{r} { }
@@ -3223,12 +3228,14 @@ struct utf8_range {
32233228
return utf8_iterator::sentinel{};
32243229
}
32253230
};
3231+
#endif
32263232

32273233
}
32283234

32293235
#endif
32303236

32313237
#endif
3238+
32323239
#include <type_traits>
32333240
#include <tuple>
32343241
#include <string_view>
@@ -5377,7 +5384,7 @@ template <typename RE, typename Method, typename Modifier> struct regular_expres
53775384
static constexpr CTRE_FORCE_INLINE auto exec(std::wstring_view sv) noexcept {
53785385
return exec(sv.begin(), sv.end());
53795386
}
5380-
#if __cpp_char8_t >= 201811
5387+
#ifdef CTRE_ENABLE_UTF8_RANGE
53815388
static constexpr CTRE_FORCE_INLINE auto exec(std::u8string_view sv) noexcept {
53825389
return exec_with_result_iterator<const char8_t *>(utf8_range(sv).begin(), utf8_range(sv).end());
53835390
}

single-header/ctre.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3028,6 +3028,10 @@ constexpr bool starts_with_anchor(const flags & f, ctll::list<capture_with_name<
30283028
#include <string_view>
30293029
#include <iterator>
30303030

3031+
#if __cpp_lib_char8_t >= 201811L
3032+
#define CTRE_ENABLE_UTF8_RANGE
3033+
#endif
3034+
30313035
namespace ctre {
30323036

30333037
struct utf8_iterator {
@@ -3209,6 +3213,7 @@ struct utf8_iterator {
32093213
}
32103214
};
32113215

3216+
#ifdef CTRE_ENABLE_UTF8_RANGE
32123217
struct utf8_range {
32133218
std::u8string_view range;
32143219
constexpr utf8_range(std::u8string_view r) noexcept: range{r} { }
@@ -3220,12 +3225,14 @@ struct utf8_range {
32203225
return utf8_iterator::sentinel{};
32213226
}
32223227
};
3228+
#endif
32233229

32243230
}
32253231

32263232
#endif
32273233

32283234
#endif
3235+
32293236
#include <type_traits>
32303237
#include <tuple>
32313238
#include <string_view>
@@ -5374,7 +5381,7 @@ template <typename RE, typename Method, typename Modifier> struct regular_expres
53745381
static constexpr CTRE_FORCE_INLINE auto exec(std::wstring_view sv) noexcept {
53755382
return exec(sv.begin(), sv.end());
53765383
}
5377-
#if __cpp_char8_t >= 201811
5384+
#ifdef CTRE_ENABLE_UTF8_RANGE
53785385
static constexpr CTRE_FORCE_INLINE auto exec(std::u8string_view sv) noexcept {
53795386
return exec_with_result_iterator<const char8_t *>(utf8_range(sv).begin(), utf8_range(sv).end());
53805387
}

tests/__utf8.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <ctre/utf8.hpp>
22
#include <algorithm>
33

4-
#if __cpp_char8_t >= 201811
4+
#ifdef CTRE_ENABLE_UTF8_RANGE
55

66
#define UNICODE_TEST(a) static_assert(call_test(u8 ##a, U ##a))
77

0 commit comments

Comments
 (0)