Skip to content

Commit 7723c4e

Browse files
author
Hana Dusíková
committed
remove <array> include
1 parent 02334e9 commit 7723c4e

File tree

5 files changed

+67
-51
lines changed

5 files changed

+67
-51
lines changed

include/ctre/actions/properties.inc.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ template <auto... Str, auto V, typename... Ts, typename Parameters> static const
2222
// make_property
2323
template <auto V, auto... Name, typename... Ts, typename Parameters> static constexpr auto apply(pcre::make_property, ctll::term<V>, [[maybe_unused]] pcre_context<ctll::list<property_name<Name...>, Ts...>, Parameters> subject) {
2424
//return ctll::reject{};
25-
constexpr std::array<char, sizeof...(Name)> name{static_cast<char>(Name)...};
25+
constexpr char name[sizeof...(Name)]{static_cast<char>(Name)...};
2626
constexpr auto p = uni::detail::binary_prop_from_string(get_string_view(name));
2727

2828
if constexpr (uni::detail::is_unknown(p)) {
@@ -48,7 +48,7 @@ template <auto V, auto... Value, auto... Name, typename... Ts, typename Paramete
4848
// make_property_negative
4949
template <auto V, auto... Name, typename... Ts, typename Parameters> static constexpr auto apply(pcre::make_property_negative, ctll::term<V>, [[maybe_unused]] pcre_context<ctll::list<property_name<Name...>, Ts...>, Parameters> subject) {
5050
//return ctll::reject{};
51-
constexpr std::array<char, sizeof...(Name)> name{static_cast<char>(Name)...};
51+
constexpr char name[sizeof...(Name)]{static_cast<char>(Name)...};
5252
constexpr auto p = uni::detail::binary_prop_from_string(get_string_view(name));
5353

5454
if constexpr (uni::detail::is_unknown(p)) {

include/ctre/atoms_unicode.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
// master branch is not including unicode db (for now)
55
#include "../unicode-db/unicode_interface.hpp"
6-
#include <array>
76

87
namespace ctre {
98

@@ -12,8 +11,8 @@ namespace ctre {
1211
template <auto... Str> struct property_name { };
1312
template <auto... Str> struct property_value { };
1413

15-
template <size_t Sz> constexpr std::string_view get_string_view(const std::array<char, Sz> & arr) noexcept {
16-
return std::string_view(arr.data(), arr.size());
14+
template <size_t Sz> constexpr std::string_view get_string_view(const char (& arr)[Sz]) noexcept {
15+
return std::string_view(arr, Sz);
1716
}
1817

1918

@@ -89,7 +88,7 @@ template <property_type Property> struct property_type_builder {
8988
};
9089

9190
template <auto... Name> struct property_builder {
92-
static constexpr std::array<char, sizeof...(Name)> name{static_cast<char>(Name)...};
91+
static constexpr char name[sizeof...(Name)]{static_cast<char>(Name)...};
9392
static constexpr property_type type = property_type_from_name(get_string_view(name));
9493

9594
using helper = property_type_builder<type>;
@@ -103,7 +102,7 @@ template <auto... Name> struct property_builder {
103102

104103
template <> struct property_type_builder<property_type::script> {
105104
template <auto... Value> static constexpr auto get() {
106-
constexpr std::array<char, sizeof...(Value)> value{Value...};
105+
constexpr char value[sizeof...(Value)]{static_cast<char>(Value)...};
107106
constexpr auto sc = uni::detail::script_from_string(get_string_view(value));
108107
if constexpr (uni::detail::is_unknown(sc)) {
109108
return ctll::reject{};
@@ -115,7 +114,7 @@ template <> struct property_type_builder<property_type::script> {
115114

116115
template <> struct property_type_builder<property_type::script_extension> {
117116
template <auto... Value> static constexpr auto get() {
118-
constexpr std::array<char, sizeof...(Value)> value{Value...};
117+
constexpr char value[sizeof...(Value)]{static_cast<char>(Value)...};
119118
constexpr auto sc = uni::detail::script_from_string(get_string_view(value));
120119
if constexpr (uni::detail::is_unknown(sc)) {
121120
return ctll::reject{};
@@ -127,7 +126,7 @@ template <> struct property_type_builder<property_type::script_extension> {
127126

128127
template <> struct property_type_builder<property_type::age> {
129128
template <auto... Value> static constexpr auto get() {
130-
constexpr std::array<char, sizeof...(Value)> value{Value...};
129+
constexpr char value[sizeof...(Value)]{static_cast<char>(Value)...};
131130
constexpr auto age = uni::detail::age_from_string(get_string_view(value));
132131
if constexpr (uni::detail::is_unassigned(age)) {
133132
return ctll::reject{};
@@ -139,7 +138,7 @@ template <> struct property_type_builder<property_type::age> {
139138

140139
template <> struct property_type_builder<property_type::block> {
141140
template <auto... Value> static constexpr auto get() {
142-
constexpr std::array<char, sizeof...(Value)> value{Value...};
141+
constexpr char value[sizeof...(Value)]{static_cast<char>(Value)...};
143142
constexpr auto block = uni::detail::block_from_string(get_string_view(value));
144143
if constexpr (uni::detail::is_unknown(block)) {
145144
return ctll::reject{};

single-header/ctre-unicode.hpp

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -460,30 +460,40 @@ struct bool_trie {
460460
constexpr bool lookup(char32_t u) const {
461461
std::uint32_t c = u;
462462
if(c < 0x800) {
463-
if constexpr(r1_s == 0)
463+
if constexpr(r1_s == 0) {
464464
return false;
465-
return trie_range_leaf(c, r1[c >> 6]);
465+
} else {
466+
return trie_range_leaf(c, r1[c >> 6]);
467+
}
466468
} else if(c < 0x10000) {
467-
if constexpr(r3_s == 0)
469+
if constexpr(r3_s == 0) {
468470
return false;
469-
std::size_t i = ((c >> 6) - 0x20);
470-
auto child = 0;
471-
if(i >= r2_t_f && i < r2_t_f + r2_s)
472-
child = r2[i - r2_t_f];
473-
474-
return trie_range_leaf(c, r3[child]);
471+
} else {
472+
std::size_t i = ((c >> 6) - 0x20);
473+
auto child = 0;
474+
if(i >= r2_t_f && i < r2_t_f + r2_s)
475+
child = r2[i - r2_t_f];
476+
return trie_range_leaf(c, r3[child]);
477+
}
475478
} else {
476-
if constexpr(r6_s == 0)
479+
if constexpr(r6_s == 0) {
477480
return false;
481+
}
478482
std::size_t i4 = (c >> 12) - 0x10;
479483
auto child = 0;
480-
if(i4 >= r4_t_f && i4 < r4_t_f + r4_s)
481-
child = r4[i4 - r4_t_f];
484+
if constexpr(r4_s > 0) {
485+
if(i4 >= r4_t_f && i4 < r4_t_f + r4_s) {
486+
child = r4[i4 - r4_t_f];
487+
}
488+
}
482489

483490
std::size_t i5 = (child << 6) + ((c >> 6) & 0x3f);
484491
auto leaf = 0;
485-
if(i5 >= r5_t_f && i5 < r5_t_f + r5_s)
486-
leaf = r5[i5 - r5_t_f];
492+
if constexpr(r5_s > 0) {
493+
if(i5 >= r5_t_f && i5 < r5_t_f + r5_s) {
494+
leaf = r5[i5 - r5_t_f];
495+
}
496+
}
487497
return trie_range_leaf(c, r6[leaf]);
488498
}
489499
}

single-header/ctre.hpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,17 +1560,15 @@ namespace uni
15601560

15611561
#endif
15621562

1563-
#include <array>
1564-
15651563
namespace ctre {
15661564

15671565
// properties name & value
15681566

15691567
template <auto... Str> struct property_name { };
15701568
template <auto... Str> struct property_value { };
15711569

1572-
template <size_t Sz> constexpr std::string_view get_string_view(const std::array<char, Sz> & arr) noexcept {
1573-
return std::string_view(arr.data(), arr.size());
1570+
template <size_t Sz> constexpr std::string_view get_string_view(const char (& arr)[Sz]) noexcept {
1571+
return std::string_view(arr, Sz);
15741572
}
15751573

15761574
// basic support for binary and type-value properties
@@ -1645,7 +1643,7 @@ template <property_type Property> struct property_type_builder {
16451643
};
16461644

16471645
template <auto... Name> struct property_builder {
1648-
static constexpr std::array<char, sizeof...(Name)> name{static_cast<char>(Name)...};
1646+
static constexpr char name[sizeof...(Name)]{static_cast<char>(Name)...};
16491647
static constexpr property_type type = property_type_from_name(get_string_view(name));
16501648

16511649
using helper = property_type_builder<type>;
@@ -1659,7 +1657,7 @@ template <auto... Name> struct property_builder {
16591657

16601658
template <> struct property_type_builder<property_type::script> {
16611659
template <auto... Value> static constexpr auto get() {
1662-
constexpr std::array<char, sizeof...(Value)> value{Value...};
1660+
constexpr char value[sizeof...(Value)]{static_cast<char>(Value)...};
16631661
constexpr auto sc = uni::detail::script_from_string(get_string_view(value));
16641662
if constexpr (uni::detail::is_unknown(sc)) {
16651663
return ctll::reject{};
@@ -1671,7 +1669,7 @@ template <> struct property_type_builder<property_type::script> {
16711669

16721670
template <> struct property_type_builder<property_type::script_extension> {
16731671
template <auto... Value> static constexpr auto get() {
1674-
constexpr std::array<char, sizeof...(Value)> value{Value...};
1672+
constexpr char value[sizeof...(Value)]{static_cast<char>(Value)...};
16751673
constexpr auto sc = uni::detail::script_from_string(get_string_view(value));
16761674
if constexpr (uni::detail::is_unknown(sc)) {
16771675
return ctll::reject{};
@@ -1683,7 +1681,7 @@ template <> struct property_type_builder<property_type::script_extension> {
16831681

16841682
template <> struct property_type_builder<property_type::age> {
16851683
template <auto... Value> static constexpr auto get() {
1686-
constexpr std::array<char, sizeof...(Value)> value{Value...};
1684+
constexpr char value[sizeof...(Value)]{static_cast<char>(Value)...};
16871685
constexpr auto age = uni::detail::age_from_string(get_string_view(value));
16881686
if constexpr (uni::detail::is_unassigned(age)) {
16891687
return ctll::reject{};
@@ -1695,7 +1693,7 @@ template <> struct property_type_builder<property_type::age> {
16951693

16961694
template <> struct property_type_builder<property_type::block> {
16971695
template <auto... Value> static constexpr auto get() {
1698-
constexpr std::array<char, sizeof...(Value)> value{Value...};
1696+
constexpr char value[sizeof...(Value)]{static_cast<char>(Value)...};
16991697
constexpr auto block = uni::detail::block_from_string(get_string_view(value));
17001698
if constexpr (uni::detail::is_unknown(block)) {
17011699
return ctll::reject{};
@@ -2303,7 +2301,7 @@ template <auto... Str, auto V, typename... Ts, typename Parameters> static const
23032301
// make_property
23042302
template <auto V, auto... Name, typename... Ts, typename Parameters> static constexpr auto apply(pcre::make_property, ctll::term<V>, [[maybe_unused]] pcre_context<ctll::list<property_name<Name...>, Ts...>, Parameters> subject) {
23052303
//return ctll::reject{};
2306-
constexpr std::array<char, sizeof...(Name)> name{static_cast<char>(Name)...};
2304+
constexpr char name[sizeof...(Name)]{static_cast<char>(Name)...};
23072305
constexpr auto p = uni::detail::binary_prop_from_string(get_string_view(name));
23082306

23092307
if constexpr (uni::detail::is_unknown(p)) {
@@ -2328,7 +2326,7 @@ template <auto V, auto... Value, auto... Name, typename... Ts, typename Paramete
23282326
// make_property_negative
23292327
template <auto V, auto... Name, typename... Ts, typename Parameters> static constexpr auto apply(pcre::make_property_negative, ctll::term<V>, [[maybe_unused]] pcre_context<ctll::list<property_name<Name...>, Ts...>, Parameters> subject) {
23302328
//return ctll::reject{};
2331-
constexpr std::array<char, sizeof...(Name)> name{static_cast<char>(Name)...};
2329+
constexpr char name[sizeof...(Name)]{static_cast<char>(Name)...};
23322330
constexpr auto p = uni::detail::binary_prop_from_string(get_string_view(name));
23332331

23342332
if constexpr (uni::detail::is_unknown(p)) {

single-header/unicode-db.hpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -239,31 +239,40 @@ struct bool_trie {
239239
constexpr bool lookup(char32_t u) const {
240240
std::uint32_t c = u;
241241
if(c < 0x800) {
242-
if constexpr(r1_s == 0)
242+
if constexpr(r1_s == 0) {
243243
return false;
244-
return trie_range_leaf(c, r1[c >> 6]);
244+
} else {
245+
return trie_range_leaf(c, r1[c >> 6]);
246+
}
245247
} else if(c < 0x10000) {
246-
if constexpr(r3_s == 0)
248+
if constexpr(r3_s == 0) {
247249
return false;
248-
std::size_t i = ((c >> 6) - 0x20);
249-
auto child = 0;
250-
if(i >= r2_t_f && i < r2_t_f + r2_s)
251-
child = r2[i - r2_t_f];
252-
253-
return trie_range_leaf(c, r3[child]);
250+
} else {
251+
std::size_t i = ((c >> 6) - 0x20);
252+
auto child = 0;
253+
if(i >= r2_t_f && i < r2_t_f + r2_s)
254+
child = r2[i - r2_t_f];
255+
return trie_range_leaf(c, r3[child]);
256+
}
254257
} else {
255-
if constexpr(r6_s == 0)
258+
if constexpr(r6_s == 0) {
256259
return false;
260+
}
257261
std::size_t i4 = (c >> 12) - 0x10;
258262
auto child = 0;
259-
if(i4 >= r4_t_f && i4 < r4_t_f + r4_s)
260-
child = r4[i4 - r4_t_f];
261-
263+
if constexpr(r4_s > 0) {
264+
if(i4 >= r4_t_f && i4 < r4_t_f + r4_s) {
265+
child = r4[i4 - r4_t_f];
266+
}
267+
}
262268

263269
std::size_t i5 = (child << 6) + ((c >> 6) & 0x3f);
264270
auto leaf = 0;
265-
if(i5 >= r5_t_f && i5 < r5_t_f + r5_s)
266-
leaf = r5[i5 - r5_t_f];
271+
if constexpr(r5_s > 0) {
272+
if(i5 >= r5_t_f && i5 < r5_t_f + r5_s) {
273+
leaf = r5[i5 - r5_t_f];
274+
}
275+
}
267276
return trie_range_leaf(c, r6[leaf]);
268277
}
269278
}
@@ -9681,4 +9690,4 @@ constexpr bool is_unknown(binary_prop s)
96819690
return s == binary_prop::unknown;
96829691
}
96839692

9684-
} // namespace uni::detail
9693+
} // namespace uni::detail

0 commit comments

Comments
 (0)