Skip to content

Commit 310ab4e

Browse files
author
Hana Dusíková
committed
single header update
1 parent 523b3bb commit 310ab4e

File tree

2 files changed

+126
-98
lines changed

2 files changed

+126
-98
lines changed

single-header/ctre-unicode.hpp

Lines changed: 63 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,69 +1949,83 @@ template <auto V> struct rotate_value {
19491949
template <auto... Vs> friend constexpr auto operator+(string<Vs...>, rotate_value<V>) noexcept -> string<V, Vs...> { return {}; }
19501950
};
19511951

1952+
struct rotate_for_lookbehind {
1953+
19521954
// from atoms_characters.hpp
1953-
template <auto V> auto rotate(character<V>) -> character<V>;
1954-
template <typename... Content> auto rotate(negative_set<Content...>) -> negative_set<Content...>;
1955-
template <typename... Content> auto rotate(set<Content...>) -> set<Content...>;
1956-
template <auto... Cs> auto rotate(enumeration<Cs...>) -> enumeration<Cs...>;
1957-
template <typename... Content> auto rotate(negate<Content...>) -> negate<Content...>;
1958-
template <auto A, auto B> auto rotate(char_range<A,B>) -> char_range<A,B>;
1955+
template <auto V> static auto rotate(character<V>) -> character<V>;
1956+
template <typename... Content> static auto rotate(negative_set<Content...>) -> negative_set<Content...>;
1957+
template <typename... Content> static auto rotate(set<Content...>) -> set<Content...>;
1958+
template <auto... Cs> static auto rotate(enumeration<Cs...>) -> enumeration<Cs...>;
1959+
template <typename... Content> static auto rotate(negate<Content...>) -> negate<Content...>;
1960+
template <auto A, auto B> static auto rotate(char_range<A,B>) -> char_range<A,B>;
19591961

19601962
// from atoms_unicode.hpp
1961-
template <auto... Str> auto rotate(property_name<Str...>) -> property_name<Str...>;
1962-
template <auto... Str> auto rotate(property_value<Str...>) -> property_value<Str...>;
1963-
template <typename T, T Type> auto rotate(binary_property<T, Type>) -> binary_property<T, Type>;
1964-
template <typename T, T Type, auto Value> auto rotate(property<T, Type, Value>) -> property<T, Type, Value>;
1963+
template <auto... Str> static auto rotate(property_name<Str...>) -> property_name<Str...>;
1964+
template <auto... Str> static auto rotate(property_value<Str...>) -> property_value<Str...>;
1965+
template <typename T, T Type> static auto rotate(binary_property<T, Type>) -> binary_property<T, Type>;
1966+
template <typename T, T Type, auto Value> static auto rotate(property<T, Type, Value>) -> property<T, Type, Value>;
19651967

19661968
// from atoms.hpp
1967-
auto rotate(accept) -> accept;
1968-
auto rotate(reject) -> reject;
1969-
auto rotate(start_mark) -> start_mark;
1970-
auto rotate(end_mark) -> end_mark;
1971-
auto rotate(end_cycle_mark) -> end_cycle_mark;
1972-
auto rotate(end_lookahead_mark) -> end_lookahead_mark;
1973-
auto rotate(end_lookbehind_mark) -> end_lookbehind_mark;
1974-
template <size_t Id> auto rotate(numeric_mark<Id>) -> numeric_mark<Id>;
1975-
auto rotate(any) -> any;
1969+
static auto rotate(accept) -> accept;
1970+
static auto rotate(reject) -> reject;
1971+
static auto rotate(start_mark) -> start_mark;
1972+
static auto rotate(end_mark) -> end_mark;
1973+
static auto rotate(end_cycle_mark) -> end_cycle_mark;
1974+
static auto rotate(end_lookahead_mark) -> end_lookahead_mark;
1975+
static auto rotate(end_lookbehind_mark) -> end_lookbehind_mark;
1976+
template <size_t Id> static auto rotate(numeric_mark<Id>) -> numeric_mark<Id>;
1977+
static auto rotate(any) -> any;
19761978

1977-
template <typename... Content> auto rotate(select<Content...>) -> select<Content...>;
1978-
auto rotate(empty) -> empty;
1979+
template <typename... Content> static auto rotate(select<Content...>) -> select<Content...>;
1980+
static auto rotate(empty) -> empty;
19791981

1980-
template <size_t a, size_t b, typename... Content> auto rotate(repeat<a,b,Content...>) -> decltype(ctre::convert_to_repeat<repeat, a, b>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{})));
1981-
template <size_t a, size_t b, typename... Content> auto rotate(lazy_repeat<a,b,Content...>) -> decltype(ctre::convert_to_repeat<lazy_repeat, a, b>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{})));
1982-
template <size_t a, size_t b, typename... Content> auto rotate(possessive_repeat<a,b,Content...>) -> decltype(ctre::convert_to_repeat<possessive_repeat, a, b>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{})));
1982+
template <size_t a, size_t b, typename... Content> static auto rotate(repeat<a,b,Content...>) -> decltype(ctre::convert_to_repeat<repeat, a, b>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{})));
1983+
template <size_t a, size_t b, typename... Content> static auto rotate(lazy_repeat<a,b,Content...>) -> decltype(ctre::convert_to_repeat<lazy_repeat, a, b>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{})));
1984+
template <size_t a, size_t b, typename... Content> static auto rotate(possessive_repeat<a,b,Content...>) -> decltype(ctre::convert_to_repeat<possessive_repeat, a, b>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{})));
19831985

1984-
template <size_t Index, typename... Content> auto rotate(capture<Index, Content...>) -> decltype(ctre::convert_to_capture<Index>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{})));
1985-
template <size_t Index, typename Name, typename... Content> auto rotate(capture_with_name<Index, Name, Content...>) -> decltype(ctre::convert_to_named_capture<Index, Name>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{})));
1986+
template <size_t Index, typename... Content> static auto rotate(capture<Index, Content...>) {
1987+
return ctre::convert_to_capture<Index>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{}));
1988+
}
19861989

1987-
template <size_t Index> auto rotate(back_reference<Index>) -> back_reference<Index>;
1988-
template <typename Name> auto rotate(back_reference_with_name<Name>) -> back_reference_with_name<Name>;
1990+
template <size_t Index, typename Name, typename... Content> static auto rotate(capture_with_name<Index, Name, Content...>) {
1991+
return ctre::convert_to_named_capture<Index, Name>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{}));
1992+
}
19891993

1990-
template <typename... Content> auto rotate(look_start<Content...>) -> look_start<Content...>;
1994+
template <size_t Index> static auto rotate(back_reference<Index>) -> back_reference<Index>;
1995+
template <typename Name> static auto rotate(back_reference_with_name<Name>) -> back_reference_with_name<Name>;
19911996

1992-
template <auto... Str> constexpr auto rotate(string<Str...>) -> decltype((string<>{} + ... + rotate_value<Str>{}));
1997+
template <typename... Content> static auto rotate(look_start<Content...>) -> look_start<Content...>;
19931998

1994-
template <typename... Content> auto rotate(sequence<Content...>) -> decltype(ctre::convert_to_basic_list<sequence>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{})));
1999+
template <auto... Str> static auto rotate(string<Str...>) -> decltype((string<>{} + ... + rotate_value<Str>{}));
2000+
2001+
template <typename... Content> static auto rotate(sequence<Content...>) {
2002+
return ctre::convert_to_basic_list<sequence>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{}));
2003+
}
19952004

19962005
// we don't rotate lookaheads
1997-
template <typename... Content> auto rotate(lookahead_positive<Content...>) -> lookahead_positive<Content...>;
1998-
template <typename... Content> auto rotate(lookahead_negative<Content...>) -> lookahead_negative<Content...>;
1999-
template <typename... Content> auto rotate(lookbehind_positive<Content...>) -> lookbehind_positive<Content...>;
2000-
template <typename... Content> auto rotate(lookbehind_negative<Content...>) -> lookbehind_negative<Content...>;
2006+
template <typename... Content> static auto rotate(lookahead_positive<Content...>) -> lookahead_positive<Content...>;
2007+
template <typename... Content> static auto rotate(lookahead_negative<Content...>) -> lookahead_negative<Content...>;
2008+
template <typename... Content> static auto rotate(lookbehind_positive<Content...>) -> lookbehind_positive<Content...>;
2009+
template <typename... Content> static auto rotate(lookbehind_negative<Content...>) -> lookbehind_negative<Content...>;
20012010

2002-
auto rotate(atomic_start) -> atomic_start;
2011+
static auto rotate(atomic_start) -> atomic_start;
20032012

2004-
template <typename... Content> auto rotate(atomic_group<Content...>) -> decltype(ctre::convert_to_basic_list<atomic_group>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{})));
2013+
template <typename... Content> static auto rotate(atomic_group<Content...>) {
2014+
return ctre::convert_to_basic_list<atomic_group>(ctll::rotate(ctll::list<decltype(rotate(Content{}))...>{}));
2015+
}
20052016

2006-
template <typename... Content> auto rotate(boundary<Content...>) -> boundary<Content...>;
2007-
template <typename... Content> auto rotate(not_boundary<Content...>) -> not_boundary<Content...>;
2017+
template <typename... Content> static auto rotate(boundary<Content...>) -> boundary<Content...>;
2018+
template <typename... Content> static auto rotate(not_boundary<Content...>) -> not_boundary<Content...>;
20082019

2009-
auto rotate(assert_subject_begin) -> assert_subject_begin;
2010-
auto rotate(assert_subject_end) -> assert_subject_end;
2011-
auto rotate(assert_subject_end_line) -> assert_subject_end_line;
2012-
auto rotate(assert_line_begin) -> assert_line_begin;
2013-
auto rotate(assert_line_end) -> assert_line_end;
2014-
2020+
static auto rotate(assert_subject_begin) -> assert_subject_begin;
2021+
static auto rotate(assert_subject_end) -> assert_subject_end;
2022+
static auto rotate(assert_subject_end_line) -> assert_subject_end_line;
2023+
static auto rotate(assert_line_begin) -> assert_line_begin;
2024+
static auto rotate(assert_line_end) -> assert_line_end;
2025+
2026+
};
2027+
2028+
decltype(ctre::rotate_for_lookbehind::rotate(ctre::capture<1, ctre::string<'a', 'b'> >{})) i;
20152029

20162030
}
20172031

@@ -2439,12 +2453,12 @@ template <auto V, typename... Ts, size_t Counter> static constexpr auto apply(pc
24392453

24402454
// lookbehind positive end
24412455
template <auto V, typename Look, typename... Ts, size_t Counter> static constexpr auto apply(pcre::look_finish, ctll::term<V>, pcre_context<ctll::list<Look, look_start<lookbehind_positive<>>, Ts...>, pcre_parameters<Counter>>) {
2442-
return pcre_context{ctll::list<lookbehind_positive<decltype(ctre::rotate(Look{}))>, Ts...>(), pcre_parameters<Counter>()};
2456+
return pcre_context{ctll::list<lookbehind_positive<decltype(ctre::rotate_for_lookbehind::rotate(Look{}))>, Ts...>(), pcre_parameters<Counter>()};
24432457
}
24442458

24452459
// lookbehind positive end (sequence)
24462460
template <auto V, typename... Look, typename... Ts, size_t Counter> static constexpr auto apply(pcre::look_finish, ctll::term<V>, pcre_context<ctll::list<ctre::sequence<Look...>, look_start<lookbehind_positive<>>, Ts...>, pcre_parameters<Counter>>) {
2447-
using my_lookbehind = decltype(ctre::convert_to_basic_list<lookbehind_positive>(ctll::rotate(ctll::list<decltype(rotate(Look{}))...>{})));
2461+
using my_lookbehind = decltype(ctre::convert_to_basic_list<lookbehind_positive>(ctll::rotate(ctll::list<decltype(ctre::rotate_for_lookbehind::rotate(Look{}))...>{})));
24482462
return pcre_context{ctll::list<my_lookbehind, Ts...>(), pcre_parameters<Counter>()};
24492463
}
24502464

@@ -2455,12 +2469,12 @@ template <auto V, typename... Ts, size_t Counter> static constexpr auto apply(pc
24552469

24562470
// lookbehind negative end
24572471
template <auto V, typename Look, typename... Ts, size_t Counter> static constexpr auto apply(pcre::look_finish, ctll::term<V>, pcre_context<ctll::list<Look, look_start<lookbehind_negative<>>, Ts...>, pcre_parameters<Counter>>) {
2458-
return pcre_context{ctll::list<lookbehind_negative<decltype(ctre::rotate(Look{}))>, Ts...>(), pcre_parameters<Counter>()};
2472+
return pcre_context{ctll::list<lookbehind_negative<decltype(ctre::rotate_for_lookbehind::rotate(Look{}))>, Ts...>(), pcre_parameters<Counter>()};
24592473
}
24602474

24612475
// lookbehind negative end (sequence)
24622476
template <auto V, typename... Look, typename... Ts, size_t Counter> static constexpr auto apply(pcre::look_finish, ctll::term<V>, pcre_context<ctll::list<ctre::sequence<Look...>, look_start<lookbehind_negative<>>, Ts...>, pcre_parameters<Counter>>) {
2463-
using my_lookbehind = decltype(ctre::convert_to_basic_list<lookbehind_negative>(ctll::rotate(ctll::list<decltype(rotate(Look{}))...>{})));
2477+
using my_lookbehind = decltype(ctre::convert_to_basic_list<lookbehind_negative>(ctll::rotate(ctll::list<decltype(ctre::rotate_for_lookbehind::rotate(Look{}))...>{})));
24642478
return pcre_context{ctll::list<my_lookbehind, Ts...>(), pcre_parameters<Counter>()};
24652479
}
24662480

0 commit comments

Comments
 (0)