diff --git a/regression-tests/pure2-regex_20_lookbehind.cpp2 b/regression-tests/pure2-regex_20_lookbehind.cpp2 new file mode 100644 index 0000000000..75ad0ade51 --- /dev/null +++ b/regression-tests/pure2-regex_20_lookbehind.cpp2 @@ -0,0 +1,286 @@ +create_result: (resultExpr: std::string, r) -> std::string = { + result: std::string = ""; + + get_next := :(iter) -> _ = { + start := std::distance(resultExpr&$*.cbegin(), iter); + firstDollar := resultExpr&$*.find("$", start); + firstAt := resultExpr&$*.find("@", start); + + end := std::min(firstDollar, firstAt); + if end != std::string::npos { + return resultExpr&$*.cbegin() + end; + } + else { + return resultExpr&$*.cend(); + } + }; + extract_group_and_advance := :(inout iter) -> _ = { + start := iter; + + while std::isdigit(iter*) next iter++ {} + + return std::stoi(std::string(start, iter)); + }; + extract_until := :(inout iter, to: char) -> _ = { + start := iter; + + while (to != iter*) next iter++ {} // TODO: Without bracket: error: postfix unary * (dereference) cannot be immediately followed by a (, identifier, or literal - add whitespace before * here if you meant binary * (multiplication) + + return std::string(start, iter); + }; + + iter := resultExpr.begin(); + + while iter != resultExpr.end() { + next := get_next(iter); + + if next != iter { + result += std::string(iter, next); + } + if next != resultExpr.end() { + if next* == '$' { + next++; + + if next* == '&' { + next++; + result += r.group(0); + } + else if next* == '-' || next* == '+' { + is_start := next* == '-'; + next++; + if next* == '{' { + next++; // Skip { + group := extract_until(next, '}'); + next++; // Skip } + result += r.group(group); + } + else if next* == '[' { + next++; // Skip [ + group := extract_group_and_advance(next); + next++; // Skip ] + + if is_start { + result += std::to_string(r.group_start(group)); + } + else { + result += std::to_string(r.group_end(group)); + } + } + else { + // Return max group + result += r.group(r.group_number() - 1); + } + } + else if std::isdigit(next*) { + group := extract_group_and_advance(next); + result += r.group(group); + } + else { + std::cerr << "Not implemented"; + } + } + else if next* == '@' { + next++; + + if next* == '-' || next* == '+' { + i := 0; + while i < cpp2::unchecked_narrow(r.group_number()) next i++ { + pos := 0; + if next* == '-' { + pos = r.group_start(i); + } + else { + pos = r.group_end(i); + } + result += std::to_string(pos); + } + next++; + } + else { + std::cerr << "Not implemented"; + } + } + else { + std::cerr << "Not implemented."; + } + } + iter = next; + } + + return result; +} + +sanitize: (copy str: std::string) -> std::string = +{ + str = cpp2::string_util::replace_all(str, "\a", "\\a"); + str = cpp2::string_util::replace_all(str, "\f", "\\f"); + str = cpp2::string_util::replace_all(str, "\x1b", "\\e"); + str = cpp2::string_util::replace_all(str, "\n", "\\n"); + str = cpp2::string_util::replace_all(str, "\r", "\\r"); + str = cpp2::string_util::replace_all(str, "\t", "\\t"); + + return str; +} + +test: (regex: M, id: std::string, regex_str: std::string, str: std::string, kind: std::string, resultExpr: std::string, + resultExpected: std::string) = { + + warning: std::string = ""; + if regex.to_string() != regex_str { + warning = "Warning: Parsed regex does not match."; + } + + status: std::string = "OK"; + + r := regex.search(str); + + if "y" == kind || "yM" == kind || "yS" == kind || "yB" == kind { + if !r.matched { + status = "Failure: Regex should apply."; + } + else { + // Have a match check the result + + result := create_result(resultExpr, r); + + if result != resultExpected { + status = "Failure: Result is wrong. (is: (sanitize(result))$)"; + } + } + } + else if "n" == kind { + if r.matched { + status = "Failure: Regex should not apply. Result is '(r.group(0))$'"; + } + } else { + status = "Unknown kind '(kind)$'"; + } + + if !warning.empty() { + warning += " "; + } + std::cout << "(id)$_(kind)$: (status)$ (warning)$regex: (regex_str)$ parsed_regex: (regex.to_string())$ str: (sanitize(str))$ result_expr: (resultExpr)$ expected_results (sanitize(resultExpected))$" << std::endl; +} + + +test_tests_20_lookbehind: @regex type = { + regex_01 := R"((?<=a)b)"; + regex_02 := R"((?<=af?)b)"; + regex_03 := R"((?<=a)b)"; + regex_04 := R"((?<=a(?:fo)?)b)"; + regex_05 := R"((?<=a)b)"; + regex_06 := R"((?<=a(?:foo)?)b)"; + regex_07 := R"((?)foo)"; + regex_50 := R"((?)foo)"; + regex_51 := R"((?<=bar>ABC)foo)"; + regex_52 := R"((?ABC)foo)"; + regex_53 := R"((?<=abcd(?<=(aaaabcd))))"; + regex_54 := R"((?=xy(?<=(aaxy))))"; + regex_55 := R"((?=xy(?<=(aaxyz?))))"; + regex_56 := R"((?<=(?=(aaxy))aa))"; + run: (this) = { + std::cout << "Running tests_20_lookbehind:"<< std::endl; + test(regex_01, "01", R"((?<=a)b)", "ab", "y", R"($&)", "b"); + test(regex_02, "02", R"((?<=af?)b)", "ab", "y", R"($&)", "b"); + test(regex_03, "03", R"((?<=a)b)", "cb", "n", R"(-)", "-"); + test(regex_04, "04", R"((?<=a(?:fo)?)b)", "cb", "n", R"(-)", "-"); + test(regex_05, "05", R"((?<=a)b)", "b", "n", R"(-)", "-"); + test(regex_06, "06", R"((?<=a(?:foo)?)b)", "b", "n", R"(-)", "-"); + test(regex_07, "07", R"((?)foo)", "bar>foo", "y", R"($&)", "foo"); + test(regex_50, "50", R"((?)foo)", "bar>foo", "n", R"(-)", "-"); + test(regex_51, "51", R"((?<=bar>ABC)foo)", "bar>ABCfoo", "y", R"($&)", "foo"); + test(regex_52, "52", R"((?ABC)foo)", "bar>ABCfoo", "n", R"(-)", "-"); + test(regex_53, "53", R"((?<=abcd(?<=(aaaabcd))))", "..aaaabcd..", "y", R"($1)", "aaaabcd"); + test(regex_54, "54", R"((?=xy(?<=(aaxy))))", "..aaxy..", "y", R"($1)", "aaxy"); + test(regex_55, "55", R"((?=xy(?<=(aaxyz?))))", "..aaxy..", "y", R"($1)", "aaxy"); + test(regex_56, "56", R"((?<=(?=(aaxy))aa))", "..aaxy..", "y", R"($1)", "aaxy"); + std::cout << std::endl; + } +} +main: () = { + test_tests_20_lookbehind().run(); +} diff --git a/regression-tests/test-results/clang-12-c++20/pure2-expected-is-as.cpp.output b/regression-tests/test-results/clang-12-c++20/pure2-expected-is-as.cpp.output index 231ad619da..80a3c22f75 100644 --- a/regression-tests/test-results/clang-12-c++20/pure2-expected-is-as.cpp.output +++ b/regression-tests/test-results/clang-12-c++20/pure2-expected-is-as.cpp.output @@ -77,59 +77,59 @@ pure2-expected-is-as.cpp2:34:24: error: use of undeclared identifier 'ex1'; did __MATHCALL_VEC (exp,, (_Mdouble_ __x)); ^ In file included from pure2-expected-is-as.cpp:7: -../../../include/cpp2util.h:469:72: error: invalid application of 'sizeof' to a function type +../../../include/cpp2util.h:475:72: error: invalid application of 'sizeof' to a function type (std::is_floating_point_v && std::is_floating_point_v && sizeof(From) > sizeof(To)) || // NOLINT(misc-redundant-expression) ^~~~~~~~~~~~ -../../../include/cpp2util.h:2924:19: note: in instantiation of variable template specialization 'cpp2::impl::is_narrowing_v' requested here +../../../include/cpp2util.h:2929:19: note: in instantiation of variable template specialization 'cpp2::impl::is_narrowing_v' requested here if constexpr (is_narrowing_v) { ^ pure2-expected-is-as.cpp2:39:28: note: in instantiation of function template specialization 'cpp2::impl::as_' requested here auto val1 {cpp2::impl::as_(ex1)}; ^ In file included from pure2-expected-is-as.cpp:7: -../../../include/cpp2util.h:2944:12: error: no matching function for call to 'as' +../../../include/cpp2util.h:2949:12: error: no matching function for call to 'as' return as(CPP2_FORWARD(x)); ^~~~~ pure2-expected-is-as.cpp2:39:28: note: in instantiation of function template specialization 'cpp2::impl::as_' requested here auto val1 {cpp2::impl::as_(ex1)}; ^ -../../../include/cpp2util.h:1902:16: note: candidate template ignored: constraints not satisfied [with C = int, x:auto = double (&)(double) noexcept] +../../../include/cpp2util.h:1907:16: note: candidate template ignored: constraints not satisfied [with C = int, x:auto = double (&)(double) noexcept] constexpr auto as(auto&& x CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT_AS) -> decltype(auto) ^ -../../../include/cpp2util.h:1908:18: note: because 'std::is_scalar_v >' evaluated to false +../../../include/cpp2util.h:1913:18: note: because 'std::is_scalar_v >' evaluated to false (std::is_scalar_v && !std::is_enum_v) ^ -../../../include/cpp2util.h:1909:17: note: and 'std::is_floating_point_v >' evaluated to false +../../../include/cpp2util.h:1914:17: note: and 'std::is_floating_point_v >' evaluated to false || std::is_floating_point_v ^ -../../../include/cpp2util.h:1910:17: note: and 'std::is_base_of_v >' evaluated to false +../../../include/cpp2util.h:1915:17: note: and 'std::is_base_of_v >' evaluated to false || std::is_base_of_v ^ -../../../include/cpp2util.h:1911:17: note: and 'std::is_base_of_v, int>' evaluated to false +../../../include/cpp2util.h:1916:17: note: and 'std::is_base_of_v, int>' evaluated to false || std::is_base_of_v ^ -../../../include/cpp2util.h:1912:30: note: and 'C({std::forward(x)})' would be invalid: cannot initialize a value of type 'int' with an lvalue of type 'double (double) noexcept' +../../../include/cpp2util.h:1917:30: note: and 'C({std::forward(x)})' would be invalid: cannot initialize a value of type 'int' with an lvalue of type 'double (double) noexcept' || requires { C{CPP2_FORWARD(x)}; } ^ -../../../include/cpp2util.h:327:37: note: expanded from macro 'CPP2_FORWARD' +../../../include/cpp2util.h:333:37: note: expanded from macro 'CPP2_FORWARD' #define CPP2_FORWARD(x) std::forward(x) ^ -../../../include/cpp2util.h:2041:6: note: candidate template ignored: constraints not satisfied [with C = int, X = double (&)(double) noexcept] +../../../include/cpp2util.h:2046:6: note: candidate template ignored: constraints not satisfied [with C = int, X = double (&)(double) noexcept] auto as(X&& x CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT_AS) -> decltype(auto) ^ -../../../include/cpp2util.h:2040:23: note: because 'specialization_of_template' evaluated to false +../../../include/cpp2util.h:2045:23: note: because 'specialization_of_template' evaluated to false template< typename C, specialization_of_template X > ^ -../../../include/cpp2util.h:892:7: note: because 'specialization_of_template_helper(std::forward(x))' would be invalid: no matching function for call to 'specialization_of_template_helper' +../../../include/cpp2util.h:897:7: note: because 'specialization_of_template_helper(std::forward(x))' would be invalid: no matching function for call to 'specialization_of_template_helper' { specialization_of_template_helper(std::forward(x)) } -> std::same_as; ^ -../../../include/cpp2util.h:2088:16: note: candidate template ignored: constraints not satisfied [with T = int, X = double (&)(double) noexcept] +../../../include/cpp2util.h:2093:16: note: candidate template ignored: constraints not satisfied [with T = int, X = double (&)(double) noexcept] constexpr auto as( X && x ) -> decltype(auto) { ^ -../../../include/cpp2util.h:2087:22: note: because 'same_type_as' evaluated to false +../../../include/cpp2util.h:2092:22: note: because 'same_type_as' evaluated to false template X> ^ -../../../include/cpp2util.h:922:29: note: because 'std::same_as, std::remove_cvref_t >' evaluated to false +../../../include/cpp2util.h:927:29: note: because 'std::same_as, std::remove_cvref_t >' evaluated to false concept same_type_as = std::same_as, std::remove_cvref_t>; ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/concepts:63:19: note: because '__detail::__same_as' evaluated to false @@ -138,19 +138,19 @@ concept same_type_as = std::same_as, std::remove_cvref_t< /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/concepts:57:27: note: because 'std::is_same_v' evaluated to false concept __same_as = std::is_same_v<_Tp, _Up>; ^ -../../../include/cpp2util.h:2131:16: note: candidate template ignored: constraints not satisfied [with T = int, X = double (&)(double) noexcept] +../../../include/cpp2util.h:2136:16: note: candidate template ignored: constraints not satisfied [with T = int, X = double (&)(double) noexcept] constexpr auto as( X&& x ) -> decltype(auto) { ^ -../../../include/cpp2util.h:2130:22: note: because 'specialization_of_template' evaluated to false +../../../include/cpp2util.h:2135:22: note: because 'specialization_of_template' evaluated to false template X> ^ -../../../include/cpp2util.h:892:7: note: because 'specialization_of_template_helper(std::forward(x))' would be invalid: no matching function for call to 'specialization_of_template_helper' +../../../include/cpp2util.h:897:7: note: because 'specialization_of_template_helper(std::forward(x))' would be invalid: no matching function for call to 'specialization_of_template_helper' { specialization_of_template_helper(std::forward(x)) } -> std::same_as; ^ -../../../include/cpp2util.h:1877:16: note: candidate function template not viable: requires 0 arguments, but 1 was provided +../../../include/cpp2util.h:1882:16: note: candidate function template not viable: requires 0 arguments, but 1 was provided constexpr auto as() -> auto ^ -../../../include/cpp2util.h:1888:16: note: candidate function template not viable: requires 0 arguments, but 1 was provided +../../../include/cpp2util.h:1893:16: note: candidate function template not viable: requires 0 arguments, but 1 was provided constexpr auto as() -> auto ^ pure2-expected-is-as.cpp2:39:37: error: use of undeclared identifier 'ex1' diff --git a/regression-tests/test-results/clang-12-c++20/pure2-regex_20_lookbehind.cpp.execution b/regression-tests/test-results/clang-12-c++20/pure2-regex_20_lookbehind.cpp.execution new file mode 100644 index 0000000000..cd61d4f563 --- /dev/null +++ b/regression-tests/test-results/clang-12-c++20/pure2-regex_20_lookbehind.cpp.execution @@ -0,0 +1,58 @@ +Running tests_20_lookbehind: +01_y: OK regex: (?<=a)b parsed_regex: (?<=a)b str: ab result_expr: $& expected_results b +02_y: OK regex: (?<=af?)b parsed_regex: (?<=af?)b str: ab result_expr: $& expected_results b +03_n: OK regex: (?<=a)b parsed_regex: (?<=a)b str: cb result_expr: - expected_results - +04_n: OK regex: (?<=a(?:fo)?)b parsed_regex: (?<=a(?:fo)?)b str: cb result_expr: - expected_results - +05_n: OK regex: (?<=a)b parsed_regex: (?<=a)b str: b result_expr: - expected_results - +06_n: OK regex: (?<=a(?:foo)?)b parsed_regex: (?<=a(?:foo)?)b str: b result_expr: - expected_results - +07_y: OK regex: (?)foo parsed_regex: (?<=bar>)foo str: bar>foo result_expr: $& expected_results foo +50_n: OK regex: (?)foo parsed_regex: (?)foo str: bar>foo result_expr: - expected_results - +51_y: OK regex: (?<=bar>ABC)foo parsed_regex: (?<=bar>ABC)foo str: bar>ABCfoo result_expr: $& expected_results foo +52_n: OK regex: (?ABC)foo parsed_regex: (?ABC)foo str: bar>ABCfoo result_expr: - expected_results - +53_y: OK regex: (?<=abcd(?<=(aaaabcd))) parsed_regex: (?<=abcd(?<=(aaaabcd))) str: ..aaaabcd.. result_expr: $1 expected_results aaaabcd +54_y: OK regex: (?=xy(?<=(aaxy))) parsed_regex: (?=xy(?<=(aaxy))) str: ..aaxy.. result_expr: $1 expected_results aaxy +55_y: OK regex: (?=xy(?<=(aaxyz?))) parsed_regex: (?=xy(?<=(aaxyz?))) str: ..aaxy.. result_expr: $1 expected_results aaxy +56_y: OK regex: (?<=(?=(aaxy))aa) parsed_regex: (?<=(?=(aaxy))aa) str: ..aaxy.. result_expr: $1 expected_results aaxy + diff --git a/regression-tests/test-results/gcc-10-c++20/pure2-expected-is-as.cpp.output b/regression-tests/test-results/gcc-10-c++20/pure2-expected-is-as.cpp.output index 894358ff48..d3c176907b 100644 --- a/regression-tests/test-results/gcc-10-c++20/pure2-expected-is-as.cpp.output +++ b/regression-tests/test-results/gcc-10-c++20/pure2-expected-is-as.cpp.output @@ -33,7 +33,7 @@ pure2-expected-is-as.cpp2:85:34: error: parse error in template argument list pure2-expected-is-as.cpp2:85:159: error: parse error in template argument list In file included from pure2-expected-is-as.cpp:7: pure2-expected-is-as.cpp2:85:309: error: parse error in template argument list -../../../include/cpp2util.h:317:66: note: in definition of macro ‘CPP2_TYPEOF’ - 317 | #define CPP2_TYPEOF(x) std::remove_cvref_t +../../../include/cpp2util.h:323:66: note: in definition of macro ‘CPP2_TYPEOF’ + 323 | #define CPP2_TYPEOF(x) std::remove_cvref_t | ^ pure2-expected-is-as.cpp2:85:430: error: parse error in template argument list diff --git a/regression-tests/test-results/gcc-10-c++20/pure2-regex_20_lookbehind.cpp.execution b/regression-tests/test-results/gcc-10-c++20/pure2-regex_20_lookbehind.cpp.execution new file mode 100644 index 0000000000..cd61d4f563 --- /dev/null +++ b/regression-tests/test-results/gcc-10-c++20/pure2-regex_20_lookbehind.cpp.execution @@ -0,0 +1,58 @@ +Running tests_20_lookbehind: +01_y: OK regex: (?<=a)b parsed_regex: (?<=a)b str: ab result_expr: $& expected_results b +02_y: OK regex: (?<=af?)b parsed_regex: (?<=af?)b str: ab result_expr: $& expected_results b +03_n: OK regex: (?<=a)b parsed_regex: (?<=a)b str: cb result_expr: - expected_results - +04_n: OK regex: (?<=a(?:fo)?)b parsed_regex: (?<=a(?:fo)?)b str: cb result_expr: - expected_results - +05_n: OK regex: (?<=a)b parsed_regex: (?<=a)b str: b result_expr: - expected_results - +06_n: OK regex: (?<=a(?:foo)?)b parsed_regex: (?<=a(?:foo)?)b str: b result_expr: - expected_results - +07_y: OK regex: (?)foo parsed_regex: (?<=bar>)foo str: bar>foo result_expr: $& expected_results foo +50_n: OK regex: (?)foo parsed_regex: (?)foo str: bar>foo result_expr: - expected_results - +51_y: OK regex: (?<=bar>ABC)foo parsed_regex: (?<=bar>ABC)foo str: bar>ABCfoo result_expr: $& expected_results foo +52_n: OK regex: (?ABC)foo parsed_regex: (?ABC)foo str: bar>ABCfoo result_expr: - expected_results - +53_y: OK regex: (?<=abcd(?<=(aaaabcd))) parsed_regex: (?<=abcd(?<=(aaaabcd))) str: ..aaaabcd.. result_expr: $1 expected_results aaaabcd +54_y: OK regex: (?=xy(?<=(aaxy))) parsed_regex: (?=xy(?<=(aaxy))) str: ..aaxy.. result_expr: $1 expected_results aaxy +55_y: OK regex: (?=xy(?<=(aaxyz?))) parsed_regex: (?=xy(?<=(aaxyz?))) str: ..aaxy.. result_expr: $1 expected_results aaxy +56_y: OK regex: (?<=(?=(aaxy))aa) parsed_regex: (?<=(?=(aaxy))aa) str: ..aaxy.. result_expr: $1 expected_results aaxy + diff --git a/regression-tests/test-results/gcc-14-c++2b/pure2-regex_20_lookbehind.cpp.execution b/regression-tests/test-results/gcc-14-c++2b/pure2-regex_20_lookbehind.cpp.execution new file mode 100644 index 0000000000..cd61d4f563 --- /dev/null +++ b/regression-tests/test-results/gcc-14-c++2b/pure2-regex_20_lookbehind.cpp.execution @@ -0,0 +1,58 @@ +Running tests_20_lookbehind: +01_y: OK regex: (?<=a)b parsed_regex: (?<=a)b str: ab result_expr: $& expected_results b +02_y: OK regex: (?<=af?)b parsed_regex: (?<=af?)b str: ab result_expr: $& expected_results b +03_n: OK regex: (?<=a)b parsed_regex: (?<=a)b str: cb result_expr: - expected_results - +04_n: OK regex: (?<=a(?:fo)?)b parsed_regex: (?<=a(?:fo)?)b str: cb result_expr: - expected_results - +05_n: OK regex: (?<=a)b parsed_regex: (?<=a)b str: b result_expr: - expected_results - +06_n: OK regex: (?<=a(?:foo)?)b parsed_regex: (?<=a(?:foo)?)b str: b result_expr: - expected_results - +07_y: OK regex: (?)foo parsed_regex: (?<=bar>)foo str: bar>foo result_expr: $& expected_results foo +50_n: OK regex: (?)foo parsed_regex: (?)foo str: bar>foo result_expr: - expected_results - +51_y: OK regex: (?<=bar>ABC)foo parsed_regex: (?<=bar>ABC)foo str: bar>ABCfoo result_expr: $& expected_results foo +52_n: OK regex: (?ABC)foo parsed_regex: (?ABC)foo str: bar>ABCfoo result_expr: - expected_results - +53_y: OK regex: (?<=abcd(?<=(aaaabcd))) parsed_regex: (?<=abcd(?<=(aaaabcd))) str: ..aaaabcd.. result_expr: $1 expected_results aaaabcd +54_y: OK regex: (?=xy(?<=(aaxy))) parsed_regex: (?=xy(?<=(aaxy))) str: ..aaxy.. result_expr: $1 expected_results aaxy +55_y: OK regex: (?=xy(?<=(aaxyz?))) parsed_regex: (?=xy(?<=(aaxyz?))) str: ..aaxy.. result_expr: $1 expected_results aaxy +56_y: OK regex: (?<=(?=(aaxy))aa) parsed_regex: (?<=(?=(aaxy))aa) str: ..aaxy.. result_expr: $1 expected_results aaxy + diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_20_lookbehind.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_20_lookbehind.cpp.output new file mode 100644 index 0000000000..e8504d0490 --- /dev/null +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_20_lookbehind.cpp.output @@ -0,0 +1,71 @@ +pure2-regex_20_lookbehind.cpp +cpp2regex.h2(591): error C2668: 'std::make_reverse_iterator': ambiguous call to overloaded function +C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\xutility(2020): note: could be 'std::reverse_iterator> std::make_reverse_iterator<_T0>(_BidIt) noexcept()' [found using argument-dependent lookup] + with + [ + _Traits=std::char_traits, + _T0=std::_String_view_iterator>, + _BidIt=std::_String_view_iterator> + ] +cpp2regex.h2(188): note: or 'auto cpp2::regex::make_reverse_iterator<_T0>(const Iter &)' + with + [ + _T0=std::_String_view_iterator>, + Iter=std::_String_view_iterator> + ] +cpp2regex.h2(591): note: while trying to match the argument list '(const _T0)' + with + [ + _T0=std::_String_view_iterator> + ] +cpp2regex.h2(591): note: the template instantiation context (the oldest one first) is +pure2-regex_20_lookbehind.cpp2(225): note: see reference to function template instantiation 'void test>>(const M &,const std::string &,const std::string &,const std::string &,const std::string &,const std::string &,const std::string &)' being compiled + with + [ + M=cpp2::regex::regular_expression> + ] +pure2-regex_20_lookbehind.cpp2(135): note: while compiling class template member function 'decltype(auto) test::::operator ()(Obj &&,Params ...) noexcept() const' +pure2-regex_20_lookbehind.cpp2(135): note: while processing the default template argument of 'decltype(auto) test::::operator ()(Obj &&,Params ...) noexcept() const' +cpp2regex.h2(872): note: see reference to function template instantiation 'cpp2::regex::regular_expression>::search_return> cpp2::regex::regular_expression>::search(const std::basic_string_view<_Elem,_Traits> &) const &' being compiled + with + [ + _Traits=std::char_traits, + _Elem=char + ] +pure2-regex_20_lookbehind.cpp2(135): note: see the first reference to 'cpp2::regex::regular_expression>::search' +cpp2regex.h2(872): note: see reference to function template instantiation 'cpp2::regex::regular_expression>::search_return> cpp2::regex::regular_expression>::search>(const Iter &,const Iter &) const &' being compiled + with + [ + _Traits=std::char_traits, + Iter=std::_String_view_iterator> + ] +cpp2regex.h2(878): note: see reference to function template instantiation 'cpp2::regex::match_return cpp2::regex::regular_expression>::search_with_context(cpp2::regex::match_context &,const Iter &) const &' being compiled + with + [ + Iter=std::_String_view_iterator>, + CharT=char + ] +cpp2regex.h2(888): note: see reference to function template instantiation 'cpp2::regex::match_return test_tests_20_lookbehind::regex_01_matcher::entry(const Iter &,cpp2::regex::match_context &)' being compiled + with + [ + Iter=std::_String_view_iterator>, + CharT=char + ] +pure2-regex_20_lookbehind.cpp2(356): note: see reference to function template instantiation 'cpp2::regex::match_return test_tests_20_lookbehind::regex_01_matcher::func_0::operator ()&,cpp2::regex::true_end_func>(const Iter &,_T0,const _T1 &) const &' being compiled + with + [ + Iter=std::_String_view_iterator>, + CharT=char, + _T0=cpp2::regex::match_context>,1> &, + _T1=cpp2::regex::true_end_func + ] +pure2-regex_20_lookbehind.cpp2(324): note: see reference to function template instantiation 'bool cpp2::regex::lookbehind_token_matcher,test_tests_20_lookbehind::regex_01_matcher::func_1>(const _T0 &,_T1 &,const _T2 &)' being compiled + with + [ + Iter=std::_String_view_iterator>, + CharT=char, + _T0=std::_String_view_iterator>, + _T1=cpp2::regex::match_context>,1>, + _T2=test_tests_20_lookbehind::regex_01_matcher::func_1 + ] +cpp2regex.h2(591): error C2119: 'r': the type for 'auto' cannot be deduced from an empty initializer diff --git a/regression-tests/pure2-regex_20_lookbehind.cpp b/regression-tests/test-results/pure2-regex_20_lookbehind.cpp similarity index 99% rename from regression-tests/pure2-regex_20_lookbehind.cpp rename to regression-tests/test-results/pure2-regex_20_lookbehind.cpp index 1f549a3467..674d9ada9a 100644 --- a/regression-tests/pure2-regex_20_lookbehind.cpp +++ b/regression-tests/test-results/pure2-regex_20_lookbehind.cpp @@ -1,4 +1,5 @@ +#define CPP2_IMPORT_STD Yes #include "cpp2regex.h" //=== Cpp2 type declarations ==================================================== @@ -6,28 +7,28 @@ #include "cpp2util.h" -#line 1 "build/20_lookbehind.cpp2" +#line 1 "pure2-regex_20_lookbehind.cpp2" -#line 166 "build/20_lookbehind.cpp2" +#line 166 "pure2-regex_20_lookbehind.cpp2" class test_tests_20_lookbehind; //=== Cpp2 type definitions and function declarations =========================== -#line 1 "build/20_lookbehind.cpp2" +#line 1 "pure2-regex_20_lookbehind.cpp2" [[nodiscard]] auto create_result(cpp2::impl::in resultExpr, auto const& r) -> std::string; -#line 113 "build/20_lookbehind.cpp2" +#line 113 "pure2-regex_20_lookbehind.cpp2" [[nodiscard]] auto sanitize(std::string str) -> std::string; -#line 125 "build/20_lookbehind.cpp2" +#line 125 "pure2-regex_20_lookbehind.cpp2" template auto test(M const& regex, cpp2::impl::in id, cpp2::impl::in regex_str, cpp2::impl::in str, cpp2::impl::in kind, cpp2::impl::in resultExpr, cpp2::impl::in resultExpected) -> void; -#line 166 "build/20_lookbehind.cpp2" +#line 166 "pure2-regex_20_lookbehind.cpp2" class test_tests_20_lookbehind { -#line 223 "build/20_lookbehind.cpp2" +#line 223 "pure2-regex_20_lookbehind.cpp2" public: auto run() const& -> void; public: template class regex_01_matcher { public: template using context = cpp2::regex::match_context; @@ -1905,15 +1906,15 @@ public: [[nodiscard]] static auto to_string() -> std::string; public: auto operator=(test_tests_20_lookbehind const&) -> void = delete; -#line 283 "build/20_lookbehind.cpp2" +#line 283 "pure2-regex_20_lookbehind.cpp2" }; auto main() -> int; //=== Cpp2 function definitions ================================================= -#line 1 "build/20_lookbehind.cpp2" +#line 1 "pure2-regex_20_lookbehind.cpp2" [[nodiscard]] auto create_result(cpp2::impl::in resultExpr, auto const& r) -> std::string{ -#line 2 "build/20_lookbehind.cpp2" +#line 2 "pure2-regex_20_lookbehind.cpp2" std::string result {""}; auto get_next {[_0 = (&resultExpr)](auto const& iter) mutable -> auto{ @@ -2025,7 +2026,7 @@ auto main() -> int; return result; } -#line 113 "build/20_lookbehind.cpp2" +#line 113 "pure2-regex_20_lookbehind.cpp2" [[nodiscard]] auto sanitize(std::string str) -> std::string { str = cpp2::string_util::replace_all(str, "\a", "\\a"); @@ -2038,7 +2039,7 @@ auto main() -> int; return cpp2::move(str); } -#line 125 "build/20_lookbehind.cpp2" +#line 125 "pure2-regex_20_lookbehind.cpp2" template auto test(M const& regex, cpp2::impl::in id, cpp2::impl::in regex_str, cpp2::impl::in str, cpp2::impl::in kind, cpp2::impl::in resultExpr, cpp2::impl::in resultExpected) -> void{ @@ -2079,7 +2080,7 @@ template auto test(M const& regex, cpp2::impl::in id, c std::cout << "" + cpp2::to_string(id) + "_" + cpp2::to_string(kind) + ": " + cpp2::to_string(cpp2::move(status)) + " " + cpp2::to_string(cpp2::move(warning)) + "regex: " + cpp2::to_string(regex_str) + " parsed_regex: " + cpp2::to_string(CPP2_UFCS(to_string)(regex)) + " str: " + cpp2::to_string(sanitize(str)) + " result_expr: " + cpp2::to_string(resultExpr) + " expected_results " + cpp2::to_string(sanitize(resultExpected)) + "" << std::endl; } -#line 223 "build/20_lookbehind.cpp2" +#line 223 "pure2-regex_20_lookbehind.cpp2" auto test_tests_20_lookbehind::run() const& -> void{ std::cout << "Running tests_20_lookbehind:" << std::endl; test(regex_01, "01", R"((?<=a)b)", "ab", "y", R"($&)", "b"); @@ -8982,7 +8983,7 @@ int i{0}; template [[nodiscard]] auto test_tests_20_lookbehind::regex_56_matcher::to_string() -> std::string{return R"((?<=(?=(aaxy))aa))"; } -#line 284 "build/20_lookbehind.cpp2" +#line 284 "pure2-regex_20_lookbehind.cpp2" auto main() -> int{ CPP2_UFCS(run)(test_tests_20_lookbehind()); } diff --git a/regression-tests/test-results/pure2-regex_20_lookbehind.cpp2.output b/regression-tests/test-results/pure2-regex_20_lookbehind.cpp2.output new file mode 100644 index 0000000000..4bb5f42590 --- /dev/null +++ b/regression-tests/test-results/pure2-regex_20_lookbehind.cpp2.output @@ -0,0 +1,2 @@ +pure2-regex_20_lookbehind.cpp2... ok (all Cpp2, passes safety checks) +