From 47b23706cd132758f3cb2e29cdbf9fe789bf4cfd Mon Sep 17 00:00:00 2001 From: Herb Sutter Date: Sun, 7 Jul 2024 12:06:21 -0700 Subject: [PATCH] Enable modules build on MSVC by removing #includes when using modules Also, silence two narrowing errors MSVC reports by adding unsafe_narrow --- include/cpp2regex.h | 8 +-- include/cpp2util.h | 3 ++ include/string_util.h | 6 +-- ...mixed-bugfix-for-ufcs-non-local.cpp.output | 52 +++++++++---------- .../pure2-bugfix-for-ufcs-noexcept.cpp.output | 4 +- .../pure2-bugfix-for-ufcs-sfinae.cpp.output | 8 +-- ...mixed-bugfix-for-ufcs-non-local.cpp.output | 40 +++++++------- .../pure2-regex_01_char_matcher.cpp.output | 1 + .../pure2-regex_02_ranges.cpp.output | 1 + .../pure2-regex_03_wildcard.cpp.output | 1 + .../pure2-regex_04_start_end.cpp.output | 1 + .../pure2-regex_05_classes.cpp.output | 1 + .../pure2-regex_06_boundaries.cpp.output | 1 + .../pure2-regex_07_short_classes.cpp.output | 1 + .../pure2-regex_08_alternatives.cpp.output | 1 + .../pure2-regex_09_groups.cpp.output | 1 + .../pure2-regex_10_escapes.cpp.execution | 30 +++++------ .../pure2-regex_10_escapes.cpp.output | 4 ++ ...pure2-regex_11_group_references.cpp.output | 1 + ...pure2-regex_12_case_insensitive.cpp.output | 1 + ...re2-regex_13_posessive_modifier.cpp.output | 1 + ...re2-regex_14_multiline_modifier.cpp.output | 1 + .../pure2-regex_15_group_modifiers.cpp.output | 1 + ...2-regex_16_perl_syntax_modifier.cpp.output | 1 + .../pure2-regex_17_comments.cpp.output | 1 + .../pure2-regex_18_branch_reset.cpp.output | 1 + .../pure2-regex_19_lookahead.cpp.output | 1 + source/regex.h2 | 8 +-- 28 files changed, 103 insertions(+), 78 deletions(-) diff --git a/include/cpp2regex.h b/include/cpp2regex.h index fab070eda..13ae24f58 100644 --- a/include/cpp2regex.h +++ b/include/cpp2regex.h @@ -183,8 +183,8 @@ template class regex_generator; // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#include -#include +// #include +// #include template using matcher_wrapper_type = typename matcher_wrapper::template wrap; @@ -1606,14 +1606,14 @@ template match_return::match_return(){} if (cpp2::impl::cmp_greater_eq(group,max_groups) || !(CPP2_ASSERT_IN_BOUNDS(groups, group).matched)) { return 0; } - return std::distance(begin, CPP2_ASSERT_IN_BOUNDS(groups, group).end); + return cpp2::unsafe_narrow(std::distance(begin, CPP2_ASSERT_IN_BOUNDS(groups, group).end)); } #line 90 "regex.h2" template [[nodiscard]] auto match_context::get_group_start(auto const& group) const& -> int{ if (cpp2::impl::cmp_greater_eq(group,max_groups) || !(CPP2_ASSERT_IN_BOUNDS(groups, group).matched)) { return 0; } - return std::distance(begin, CPP2_ASSERT_IN_BOUNDS(groups, group).start); + return cpp2::unsafe_narrow(std::distance(begin, CPP2_ASSERT_IN_BOUNDS(groups, group).start)); } #line 96 "regex.h2" template [[nodiscard]] auto match_context::get_group_string(auto const& group) const& -> std::string{ diff --git a/include/cpp2util.h b/include/cpp2util.h index d04ea66bd..50277290c 100644 --- a/include/cpp2util.h +++ b/include/cpp2util.h @@ -267,6 +267,7 @@ #include #include #include + #include #include #include #include @@ -274,7 +275,9 @@ #if defined(CPP2_USE_SOURCE_LOCATION) #include #endif + #include #include + #include #include #include #include diff --git a/include/string_util.h b/include/string_util.h index 678e64343..2ce64b3d1 100644 --- a/include/string_util.h +++ b/include/string_util.h @@ -1,8 +1,8 @@ #pragma once -#include -#include -#include +// #include +// #include +// #include namespace cpp2 { namespace string_util { diff --git a/regression-tests/test-results/clang-12-c++20/mixed-bugfix-for-ufcs-non-local.cpp.output b/regression-tests/test-results/clang-12-c++20/mixed-bugfix-for-ufcs-non-local.cpp.output index 3fb13e67a..fa6f4239b 100644 --- a/regression-tests/test-results/clang-12-c++20/mixed-bugfix-for-ufcs-non-local.cpp.output +++ b/regression-tests/test-results/clang-12-c++20/mixed-bugfix-for-ufcs-non-local.cpp.output @@ -1,118 +1,118 @@ mixed-bugfix-for-ufcs-non-local.cpp2:13:12: error: a lambda expression cannot appear in this context template UnnamedTypeParam1_1> bool inline constexpr v0{ false };// Fails on GCC ([GCC109781][]) and Clang 12 (a lambda expression cannot appear in this context) ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ mixed-bugfix-for-ufcs-non-local.cpp2:15:3: error: a lambda expression cannot appear in this context t inline constexpr v1{ t() };// Fails on Clang 12 (lambda in unevaluated context). ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: error: a lambda expression cannot appear in this context template UnnamedTypeParam1_2> auto g() -> void; ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ mixed-bugfix-for-ufcs-non-local.cpp2:23:42: error: a lambda expression cannot appear in this context auto g([[maybe_unused]] cpp2::impl::in> unnamed_param_1) -> void; ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ mixed-bugfix-for-ufcs-non-local.cpp2:27:29: error: a lambda expression cannot appear in this context [[nodiscard]] auto h() -> t; ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ mixed-bugfix-for-ufcs-non-local.cpp2:31:12: error: a lambda expression cannot appear in this context template UnnamedTypeParam1_3> using a = bool;// Fails on GCC ([GCC109781][]) and Clang 12 (a lambda expression cannot appear in this context) ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ mixed-bugfix-for-ufcs-non-local.cpp2:33:12: error: a lambda expression cannot appear in this context template UnnamedTypeParam1_4> auto inline constexpr b{ false };// Fails on GCC ([GCC109781][]). ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ mixed-bugfix-for-ufcs-non-local.cpp2:35:13: error: a lambda expression cannot appear in this context using c = t;// Fails on Clang 12 (lambda in unevaluated context) and Clang 12 (a lambda expression cannot appear in this context) ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ mixed-bugfix-for-ufcs-non-local.cpp2:37:28: error: a lambda expression cannot appear in this context auto inline constexpr d{ t() };// Fails on Clang 12 (lambda in unevaluated context). ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: error: a lambda expression cannot appear in this context template UnnamedTypeParam1_2> auto g() -> void{}// Fails on GCC ([GCC109781][]) and Clang 12 (a lambda expression cannot appear in this context) ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ mixed-bugfix-for-ufcs-non-local.cpp2:23:42: error: a lambda expression cannot appear in this context auto g([[maybe_unused]] cpp2::impl::in> unnamed_param_1) -> void{}// Fails on Clang 12 (lambda in unevaluated context). ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ mixed-bugfix-for-ufcs-non-local.cpp2:27:29: error: a lambda expression cannot appear in this context [[nodiscard]] auto h() -> t { return o; }// Fails on Clang 12 (lambda in unevaluated context). ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ mixed-bugfix-for-ufcs-non-local.cpp2:41:84: error: lambda expression in an unevaluated operand inline CPP2_CONSTEXPR bool u::c{ [](cpp2::impl::in> x) mutable -> auto { return x; }(true) };// Fails on Clang 12 (lambda in unevaluated context). ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ 13 errors generated. diff --git a/regression-tests/test-results/clang-12-c++20/pure2-bugfix-for-ufcs-noexcept.cpp.output b/regression-tests/test-results/clang-12-c++20/pure2-bugfix-for-ufcs-noexcept.cpp.output index 758c43562..7c50e0c91 100644 --- a/regression-tests/test-results/clang-12-c++20/pure2-bugfix-for-ufcs-noexcept.cpp.output +++ b/regression-tests/test-results/clang-12-c++20/pure2-bugfix-for-ufcs-noexcept.cpp.output @@ -1,10 +1,10 @@ pure2-bugfix-for-ufcs-noexcept.cpp2:5:26: error: lambda expression in an unevaluated operand static_assert(noexcept(CPP2_UFCS(swap)(t(), t())));// Fails on Clang 12 (lambda in unevaluated context) and GCC 10 (static assertion failed) ^ -../../../include/cpp2util.h:1168:59: note: expanded from macro 'CPP2_UFCS' +../../../include/cpp2util.h:1171:59: note: expanded from macro 'CPP2_UFCS' #define CPP2_UFCS(...) CPP2_UFCS_(&,CPP2_UFCS_EMPTY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ 1 error generated. diff --git a/regression-tests/test-results/clang-12-c++20/pure2-bugfix-for-ufcs-sfinae.cpp.output b/regression-tests/test-results/clang-12-c++20/pure2-bugfix-for-ufcs-sfinae.cpp.output index 11853743c..515e292c0 100644 --- a/regression-tests/test-results/clang-12-c++20/pure2-bugfix-for-ufcs-sfinae.cpp.output +++ b/regression-tests/test-results/clang-12-c++20/pure2-bugfix-for-ufcs-sfinae.cpp.output @@ -1,19 +1,19 @@ pure2-bugfix-for-ufcs-sfinae.cpp2:1:78: error: lambda expression in an unevaluated operand template [[nodiscard]] auto f() -> std::type_identity_t; ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ pure2-bugfix-for-ufcs-sfinae.cpp2:1:78: error: lambda expression in an unevaluated operand template [[nodiscard]] auto f() -> std::type_identity_t{}// Fails on Clang 12 (lambda in unevaluated context). ^ -../../../include/cpp2util.h:1173:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' +../../../include/cpp2util.h:1176:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL' #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) ^ -../../../include/cpp2util.h:1135:66: note: expanded from macro 'CPP2_UFCS_' +../../../include/cpp2util.h:1138:66: note: expanded from macro 'CPP2_UFCS_' #define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \ ^ 2 errors generated. diff --git a/regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output b/regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output index d7ea10271..ee4d28d52 100644 --- a/regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output +++ b/regression-tests/test-results/gcc-14-c++2b/mixed-bugfix-for-ufcs-non-local.cpp.output @@ -1,41 +1,41 @@ In file included from mixed-bugfix-for-ufcs-non-local.cpp:6: -../../../include/cpp2util.h:1136:1: error: lambda-expression in template parameter type - 1136 | [LAMBDADEFCAPT]< \ +../../../include/cpp2util.h:1139:1: error: lambda-expression in template parameter type + 1139 | [LAMBDADEFCAPT]< \ | ^ -../../../include/cpp2util.h:1173:59: note: in expansion of macro ‘CPP2_UFCS_’ - 1173 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) +../../../include/cpp2util.h:1176:59: note: in expansion of macro ‘CPP2_UFCS_’ + 1176 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) | ^~~~~~~~~~ mixed-bugfix-for-ufcs-non-local.cpp2:13:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:13:36: error: template argument 1 is invalid -../../../include/cpp2util.h:1136:1: error: lambda-expression in template parameter type - 1136 | [LAMBDADEFCAPT]< \ +../../../include/cpp2util.h:1139:1: error: lambda-expression in template parameter type + 1139 | [LAMBDADEFCAPT]< \ | ^ -../../../include/cpp2util.h:1173:59: note: in expansion of macro ‘CPP2_UFCS_’ - 1173 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) +../../../include/cpp2util.h:1176:59: note: in expansion of macro ‘CPP2_UFCS_’ + 1176 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) | ^~~~~~~~~~ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid -../../../include/cpp2util.h:1136:1: error: lambda-expression in template parameter type - 1136 | [LAMBDADEFCAPT]< \ +../../../include/cpp2util.h:1139:1: error: lambda-expression in template parameter type + 1139 | [LAMBDADEFCAPT]< \ | ^ -../../../include/cpp2util.h:1173:59: note: in expansion of macro ‘CPP2_UFCS_’ - 1173 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) +../../../include/cpp2util.h:1176:59: note: in expansion of macro ‘CPP2_UFCS_’ + 1176 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) | ^~~~~~~~~~ mixed-bugfix-for-ufcs-non-local.cpp2:31:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:31:36: error: template argument 1 is invalid -../../../include/cpp2util.h:1136:1: error: lambda-expression in template parameter type - 1136 | [LAMBDADEFCAPT]< \ +../../../include/cpp2util.h:1139:1: error: lambda-expression in template parameter type + 1139 | [LAMBDADEFCAPT]< \ | ^ -../../../include/cpp2util.h:1173:59: note: in expansion of macro ‘CPP2_UFCS_’ - 1173 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) +../../../include/cpp2util.h:1176:59: note: in expansion of macro ‘CPP2_UFCS_’ + 1176 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) | ^~~~~~~~~~ mixed-bugfix-for-ufcs-non-local.cpp2:33:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:33:36: error: template argument 1 is invalid -../../../include/cpp2util.h:1136:1: error: lambda-expression in template parameter type - 1136 | [LAMBDADEFCAPT]< \ +../../../include/cpp2util.h:1139:1: error: lambda-expression in template parameter type + 1139 | [LAMBDADEFCAPT]< \ | ^ -../../../include/cpp2util.h:1173:59: note: in expansion of macro ‘CPP2_UFCS_’ - 1173 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) +../../../include/cpp2util.h:1176:59: note: in expansion of macro ‘CPP2_UFCS_’ + 1176 | #define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__) | ^~~~~~~~~~ mixed-bugfix-for-ufcs-non-local.cpp2:21:12: note: in expansion of macro ‘CPP2_UFCS_NONLOCAL’ mixed-bugfix-for-ufcs-non-local.cpp2:21:36: error: template argument 1 is invalid diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_01_char_matcher.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_01_char_matcher.cpp.output index e69de29bb..e74374d8c 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_01_char_matcher.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_01_char_matcher.cpp.output @@ -0,0 +1 @@ +pure2-regex_01_char_matcher.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_02_ranges.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_02_ranges.cpp.output index e69de29bb..00bf2644d 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_02_ranges.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_02_ranges.cpp.output @@ -0,0 +1 @@ +pure2-regex_02_ranges.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_03_wildcard.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_03_wildcard.cpp.output index e69de29bb..6d0365664 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_03_wildcard.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_03_wildcard.cpp.output @@ -0,0 +1 @@ +pure2-regex_03_wildcard.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_04_start_end.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_04_start_end.cpp.output index e69de29bb..e11a6a873 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_04_start_end.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_04_start_end.cpp.output @@ -0,0 +1 @@ +pure2-regex_04_start_end.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_05_classes.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_05_classes.cpp.output index e69de29bb..eb300bda6 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_05_classes.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_05_classes.cpp.output @@ -0,0 +1 @@ +pure2-regex_05_classes.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_06_boundaries.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_06_boundaries.cpp.output index e69de29bb..150c67dd3 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_06_boundaries.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_06_boundaries.cpp.output @@ -0,0 +1 @@ +pure2-regex_06_boundaries.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_07_short_classes.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_07_short_classes.cpp.output index e69de29bb..97988771c 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_07_short_classes.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_07_short_classes.cpp.output @@ -0,0 +1 @@ +pure2-regex_07_short_classes.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_08_alternatives.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_08_alternatives.cpp.output index e69de29bb..7a45b0c18 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_08_alternatives.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_08_alternatives.cpp.output @@ -0,0 +1 @@ +pure2-regex_08_alternatives.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_09_groups.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_09_groups.cpp.output index e69de29bb..047bb5f08 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_09_groups.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_09_groups.cpp.output @@ -0,0 +1 @@ +pure2-regex_09_groups.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_10_escapes.cpp.execution b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_10_escapes.cpp.execution index fe6e6efc9..f743e0fe5 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_10_escapes.cpp.execution +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_10_escapes.cpp.execution @@ -9,30 +9,30 @@ Running tests_10_escapes: 08_y: OK regex: foo(\h)bar parsed_regex: foo(\h)bar str: foo bar result_expr: $1 expected_results 09_y: OK regex: (\H)(\h) parsed_regex: (\H)(\h) str: foo bar result_expr: $1-$2 expected_results o- 10_y: OK regex: (\h)(\H) parsed_regex: (\h)(\H) str: foo bar result_expr: $1-$2 expected_results -b -11_y: OK regex: foo(\v+)bar parsed_regex: foo(\v+)bar str: foo +11_y: OK regex: foo(\v+)bar parsed_regex: foo(\v+)bar str: foo + +bar result_expr: $1 expected_results + -bar result_expr: $1 expected_results +12_y: OK regex: (\V+)(\v) parsed_regex: (\V+)(\v) str: foo + +bar result_expr: $1-$2 expected_results foo- +13_y: OK regex: (\v+)(\V) parsed_regex: (\v+)(\V) str: foo + -12_y: OK regex: (\V+)(\v) parsed_regex: (\V+)(\v) str: foo - - -bar result_expr: $1-$2 expected_results foo- -13_y: OK regex: (\v+)(\V) parsed_regex: (\v+)(\V) str: foo - - -bar result_expr: $1-$2 expected_results - +bar result_expr: $1-$2 expected_results + -b -14_y: OK regex: foo(\v)bar parsed_regex: foo(\v)bar str: foo bar result_expr: $1 expected_results -15_y: OK regex: (\V)(\v) parsed_regex: (\V)(\v) str: foo bar result_expr: $1-$2 expected_results o- +14_y: OK regex: foo(\v)bar parsed_regex: foo(\v)bar str: foo bar result_expr: $1 expected_results +15_y: OK regex: (\V)(\v) parsed_regex: (\V)(\v) str: foo bar result_expr: $1-$2 expected_results o- 16_y: OK regex: (\v)(\V) parsed_regex: (\v)(\V) str: foo bar result_expr: $1-$2 expected_results -b 17_y: OK regex: foo\t\n\r\f\a\ebar parsed_regex: foo\t\n\r\f\a\ebar str: foo - bar result_expr: $& expected_results foo - bar + ebar result_expr: $& expected_results foo + ebar 18_y: OK regex: foo\Kbar parsed_regex: foo\Kbar str: foobar result_expr: $& expected_results bar 19_y: OK regex: \x41\x42 parsed_regex: \x41\x42 str: AB result_expr: $& expected_results AB 20_y: OK regex: \101\o{102} parsed_regex: \101\o{102} str: AB result_expr: $& expected_results AB diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_10_escapes.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_10_escapes.cpp.output index e69de29bb..bcb3c878c 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_10_escapes.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_10_escapes.cpp.output @@ -0,0 +1,4 @@ +pure2-regex_10_escapes.cpp +pure2-regex_10_escapes.cpp2(192): warning C4129: 'e': unrecognized character escape sequence +pure2-regex_10_escapes.cpp2(192): warning C4129: 'e': unrecognized character escape sequence +pure2-regex_10_escapes.cpp2(1592): warning C4129: 'e': unrecognized character escape sequence diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_11_group_references.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_11_group_references.cpp.output index e69de29bb..61446dad6 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_11_group_references.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_11_group_references.cpp.output @@ -0,0 +1 @@ +pure2-regex_11_group_references.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_12_case_insensitive.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_12_case_insensitive.cpp.output index e69de29bb..1c860cd48 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_12_case_insensitive.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_12_case_insensitive.cpp.output @@ -0,0 +1 @@ +pure2-regex_12_case_insensitive.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_13_posessive_modifier.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_13_posessive_modifier.cpp.output index e69de29bb..c2f6f5644 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_13_posessive_modifier.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_13_posessive_modifier.cpp.output @@ -0,0 +1 @@ +pure2-regex_13_posessive_modifier.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_14_multiline_modifier.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_14_multiline_modifier.cpp.output index e69de29bb..9fe1dd849 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_14_multiline_modifier.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_14_multiline_modifier.cpp.output @@ -0,0 +1 @@ +pure2-regex_14_multiline_modifier.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_15_group_modifiers.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_15_group_modifiers.cpp.output index e69de29bb..25bda9273 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_15_group_modifiers.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_15_group_modifiers.cpp.output @@ -0,0 +1 @@ +pure2-regex_15_group_modifiers.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_16_perl_syntax_modifier.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_16_perl_syntax_modifier.cpp.output index e69de29bb..3df3a04bf 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_16_perl_syntax_modifier.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_16_perl_syntax_modifier.cpp.output @@ -0,0 +1 @@ +pure2-regex_16_perl_syntax_modifier.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_17_comments.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_17_comments.cpp.output index e69de29bb..7cd5b672d 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_17_comments.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_17_comments.cpp.output @@ -0,0 +1 @@ +pure2-regex_17_comments.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_18_branch_reset.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_18_branch_reset.cpp.output index e69de29bb..dac6ef8e5 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_18_branch_reset.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_18_branch_reset.cpp.output @@ -0,0 +1 @@ +pure2-regex_18_branch_reset.cpp diff --git a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_19_lookahead.cpp.output b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_19_lookahead.cpp.output index e69de29bb..005c8d5dc 100644 --- a/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_19_lookahead.cpp.output +++ b/regression-tests/test-results/msvc-2022-c++latest/pure2-regex_19_lookahead.cpp.output @@ -0,0 +1 @@ +pure2-regex_19_lookahead.cpp diff --git a/source/regex.h2 b/source/regex.h2 index 6e5061874..c8cd052ad 100644 --- a/source/regex.h2 +++ b/source/regex.h2 @@ -10,8 +10,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#include -#include +// #include +// #include template using matcher_wrapper_type = typename matcher_wrapper::template wrap; @@ -85,13 +85,13 @@ match_context: type = if group >= max_groups || !groups[group].matched { return 0; } - return std::distance(begin, groups[group].end); + return cpp2::unsafe_narrow( std::distance(begin, groups[group].end) ); } get_group_start: (in this, group) -> int = { if group >= max_groups || !groups[group].matched { return 0; } - return std::distance(begin, groups[group].start); + return cpp2::unsafe_narrow( std::distance(begin, groups[group].start) ); } get_group_string: (in this, group) -> std::string = { if group >= max_groups || !groups[group].matched {