Skip to content

Commit d71fca4

Browse files
author
Hana Dusíková
committed
Add another feature macro, inspired by a patch from JonCaves
1 parent 65b8b56 commit d71fca4

18 files changed

+61
-61
lines changed

include/ctll/parser.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ struct placeholder { };
2121

2222
template <size_t> using index_placeholder = placeholder;
2323

24-
#if !__cpp_nontype_template_parameter_class
25-
template <typename Grammar, const auto & input, typename ActionSelector = empty_actions, bool IgnoreUnknownActions = false> struct parser {
26-
#else
24+
#if ((__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L)) || (__cpp_nontype_template_args >= 201911L))
2725
template <typename Grammar, ctll::fixed_string input, typename ActionSelector = empty_actions, bool IgnoreUnknownActions = false> struct parser { // in c++20
26+
#else
27+
template <typename Grammar, const auto & input, typename ActionSelector = empty_actions, bool IgnoreUnknownActions = false> struct parser {
2828
#endif
2929

3030
#ifdef __GNUC__ // workaround to GCC bug
31-
#if __cpp_nontype_template_parameter_class
31+
#if ((__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L)) || (__cpp_nontype_template_args >= 201911L))
3232
static constexpr auto _input = input; // c++20 mode
3333
#else
3434
static constexpr auto & _input = input; // c++17 mode
@@ -46,7 +46,7 @@ template <typename Grammar, ctll::fixed_string input, typename ActionSelector =
4646
}
4747

4848
#ifdef __GNUC__ // workaround to GCC bug
49-
#if __cpp_nontype_template_parameter_class
49+
#if ((__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L)) || (__cpp_nontype_template_args >= 201911L))
5050
static constexpr auto _input = input; // c++20 mode
5151
#else
5252
static constexpr auto & _input = input; // c++17 mode

include/ctre/functions.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace ctre {
1111

12-
#if !__cpp_nontype_template_parameter_class
12+
#if !(__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
1313
// avoiding CTAD limitation in C++17
1414
template <typename CharT, size_t N> class pattern: public ctll::fixed_string<N> {
1515
using parent = ctll::fixed_string<N>;
@@ -29,7 +29,7 @@ template <typename CharT, size_t N> class fixed_string: public ctll::fixed_strin
2929
template <typename CharT, size_t N> fixed_string(const CharT (&)[N]) -> fixed_string<CharT, N>;
3030
#endif
3131

32-
#if __cpp_nontype_template_parameter_class
32+
#if (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
3333
template <ctll::fixed_string input> CTRE_FLATTEN constexpr CTRE_FORCE_INLINE auto re() noexcept {
3434
constexpr auto _input = input; // workaround for GCC 9 bug 88092
3535
#else
@@ -66,7 +66,7 @@ template <typename RE> struct regex_search_t {
6666
}
6767
};
6868

69-
#if __cpp_nontype_template_parameter_class
69+
#if (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
7070

7171
template <auto input> struct regex_builder {
7272
static constexpr auto _input = input;

include/ctre/iterators.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ template <typename Subject, typename RE> constexpr auto iterator(const Subject &
6262

6363

6464

65-
#if __cpp_nontype_template_parameter_class
65+
#if (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
6666
template <ctll::fixed_string input, typename BeginIterator, typename EndIterator> CTRE_FLATTEN constexpr CTRE_FORCE_INLINE auto iterator(BeginIterator begin, EndIterator end) noexcept {
6767
constexpr auto _input = input;
6868
using tmp = typename ctll::parser<ctre::pcre, _input, ctre::pcre_actions>::template output<pcre_context<>>;
@@ -73,7 +73,7 @@ template <ctll::fixed_string input, typename BeginIterator, typename EndIterator
7373
#endif
7474

7575

76-
#if __cpp_nontype_template_parameter_class
76+
#if (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
7777
template <ctll::fixed_string input, typename Subject> CTRE_FLATTEN constexpr CTRE_FORCE_INLINE auto iterator(const Subject & subject) noexcept {
7878
constexpr auto _input = input;
7979
using tmp = typename ctll::parser<ctre::pcre, _input, ctre::pcre_actions>::template output<pcre_context<>>;

include/ctre/literals.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace ctre {
1414
// in C++17 (clang & gcc with gnu extension) we need translate character pack into ctll::fixed_string
1515
// in C++20 we have `class nontype template parameters`
1616

17-
#if !__cpp_nontype_template_parameter_class
17+
#if !(__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
1818
template <typename CharT, CharT... input> static inline constexpr auto _fixed_string_reference = ctll::fixed_string< sizeof...(input)>({input...});
1919
#endif
2020

@@ -41,7 +41,7 @@ namespace literals {
4141
// add this when we will have concepts
4242
// requires ctll::parser<ctre::pcre, _fixed_string_reference<CharT, charpack...>, ctre::pcre_actions>::template correct_with<pcre_context<>>
4343

44-
#if !__cpp_nontype_template_parameter_class
44+
#if !(__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
4545
template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr CTRE_FORCE_INLINE auto operator""_ctre() noexcept {
4646
constexpr auto & _input = _fixed_string_reference<CharT, charpack...>;
4747
#else
@@ -61,7 +61,7 @@ template <ctll::fixed_string input> CTRE_FLATTEN constexpr CTRE_FORCE_INLINE aut
6161

6262

6363
// this will need to be fixed with C++20
64-
#if !__cpp_nontype_template_parameter_class
64+
#if !(__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
6565
template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr CTRE_FORCE_INLINE auto operator""_ctre_id() noexcept {
6666
return id<charpack...>();
6767
}
@@ -75,7 +75,7 @@ namespace test_literals {
7575

7676
#ifdef CTRE_ENABLE_LITERALS
7777

78-
#if !__cpp_nontype_template_parameter_class
78+
#if !(__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
7979
template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr inline auto operator""_ctre_test() noexcept {
8080
constexpr auto & _input = _fixed_string_reference<CharT, charpack...>;
8181
#else
@@ -85,7 +85,7 @@ template <ctll::fixed_string input> CTRE_FLATTEN constexpr inline auto operator"
8585
return ctll::parser<ctre::pcre, _input>::template correct_with<>;
8686
}
8787

88-
#if !__cpp_nontype_template_parameter_class
88+
#if !(__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
8989
template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr inline auto operator""_ctre_gen() noexcept {
9090
constexpr auto & _input = _fixed_string_reference<CharT, charpack...>;
9191
#else
@@ -98,7 +98,7 @@ template <ctll::fixed_string input> CTRE_FLATTEN constexpr inline auto operator"
9898
}
9999

100100

101-
#if !__cpp_nontype_template_parameter_class
101+
#if !(__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
102102
template <typename CharT, CharT... charpack> CTRE_FLATTEN constexpr CTRE_FORCE_INLINE auto operator""_ctre_syntax() noexcept {
103103
constexpr auto & _input = _fixed_string_reference<CharT, charpack...>;
104104
#else

include/ctre/range.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ template <typename BeginIterator, typename EndIterator, typename RE> constexpr a
2323
return regex_range<BeginIterator, EndIterator, RE>(begin, end);
2424
}
2525

26-
#if __cpp_nontype_template_parameter_class
26+
#if (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
2727
template <ctll::fixed_string input, typename BeginIterator, typename EndIterator> constexpr auto range(BeginIterator begin, EndIterator end) noexcept {
2828
constexpr auto _input = input;
2929
using tmp = typename ctll::parser<ctre::pcre, _input, ctre::pcre_actions>::template output<pcre_context<>>;
@@ -42,7 +42,7 @@ template <typename RE> constexpr auto range(const char * subject, RE re) noexcep
4242
return range(subject, zero_terminated_string_end_iterator(), re);
4343
}
4444

45-
#if __cpp_nontype_template_parameter_class
45+
#if (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
4646
template <ctll::fixed_string input, typename Subject> constexpr auto range(const Subject & subject) noexcept {
4747
constexpr auto _input = input;
4848
using tmp = typename ctll::parser<ctre::pcre, _input, ctre::pcre_actions>::template output<pcre_context<>>;

include/ctre/return_type.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ template <typename Head, typename... Tail> struct captures<Head, Tail...>: captu
112112
return captures<Tail...>::template exists<Name>();
113113
}
114114
}
115-
#if __cpp_nontype_template_parameter_class
115+
#if (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
116116
template <ctll::fixed_string Name> CTRE_FORCE_INLINE static constexpr bool exists() noexcept {
117117
#else
118118
template <const auto & Name> CTRE_FORCE_INLINE static constexpr bool exists() noexcept {
@@ -155,7 +155,7 @@ template <typename Head, typename... Tail> struct captures<Head, Tail...>: captu
155155
return captures<Tail...>::template select<Name>();
156156
}
157157
}
158-
#if __cpp_nontype_template_parameter_class
158+
#if (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
159159
template <ctll::fixed_string Name> CTRE_FORCE_INLINE constexpr auto & select() const noexcept {
160160
#else
161161
template <const auto & Name> CTRE_FORCE_INLINE constexpr auto & select() const noexcept {
@@ -180,7 +180,7 @@ template <> struct captures<> {
180180
template <typename> CTRE_FORCE_INLINE static constexpr bool exists() noexcept {
181181
return false;
182182
}
183-
#if __cpp_nontype_template_parameter_class
183+
#if (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
184184
template <ctll::fixed_string> CTRE_FORCE_INLINE static constexpr bool exists() noexcept {
185185
#else
186186
template <const auto &> CTRE_FORCE_INLINE static constexpr bool exists() noexcept {
@@ -193,7 +193,7 @@ template <> struct captures<> {
193193
template <typename> CTRE_FORCE_INLINE constexpr auto & select() const noexcept {
194194
return capture_not_exists;
195195
}
196-
#if __cpp_nontype_template_parameter_class
196+
#if (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
197197
template <ctll::fixed_string> CTRE_FORCE_INLINE constexpr auto & select() const noexcept {
198198
#else
199199
template <const auto &> CTRE_FORCE_INLINE constexpr auto & select() const noexcept {
@@ -219,7 +219,7 @@ template <typename Iterator, typename... Captures> class regex_results {
219219
template <typename Name, typename = std::enable_if_t<decltype(_captures)::template exists<Name>()>> CTRE_FORCE_INLINE constexpr auto get() const noexcept {
220220
return _captures.template select<Name>();
221221
}
222-
#if __cpp_nontype_template_parameter_class
222+
#if (__cpp_nontype_template_parameter_class || (__cpp_nontype_template_args >= 201911L))
223223
template <ctll::fixed_string Name, typename = std::enable_if_t<decltype(_captures)::template exists<Name>()>> CTRE_FORCE_INLINE constexpr auto get() const noexcept {
224224
#else
225225
template <const auto & Name, typename = std::enable_if_t<decltype(_captures)::template exists<Name>()>> CTRE_FORCE_INLINE constexpr auto get() const noexcept {

0 commit comments

Comments
 (0)