Skip to content

Commit fa21f0c

Browse files
committed
Did two minor tweaks, and updated tests
Add an array value-equality case (thanks to MSVC for warning about that) Also stop forwarding the `value` to `std::vformat` to stay compatible with the `vformat` change
1 parent 1f29e91 commit fa21f0c

File tree

37 files changed

+156
-63
lines changed

37 files changed

+156
-63
lines changed

include/cpp2util.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ inline auto to_string(std::tuple<Ts...> const& t) -> std::string
12351235
#if defined(__cpp_lib_format) || (defined(_MSC_VER) && _MSC_VER >= 1929)
12361236
inline auto to_string(auto&& value, std::string_view fmt) -> std::string
12371237
{
1238-
return std::vformat(fmt, std::make_format_args(CPP2_FORWARD(value)));
1238+
return std::vformat(fmt, std::make_format_args(value));
12391239
}
12401240
#else
12411241
inline auto to_string(auto&& value, std::string_view) -> std::string
@@ -1341,7 +1341,13 @@ inline constexpr auto is( auto const& x, auto&& value ) -> bool
13411341
return value(x);
13421342
}
13431343

1344-
// Value equality case
1344+
// Value equality case: C/C++ arrays or individual values
1345+
else if constexpr (std::is_array_v<CPP2_TYPEOF(x)> && std::is_array_v<CPP2_TYPEOF(value)>) {
1346+
if (std::ssize(x) == std::ssize(value)) {
1347+
return std::equal( std::begin(x), std::end(x), std::begin(value));
1348+
}
1349+
return false;
1350+
}
13451351
else if constexpr (requires{ bool{x == value}; }) {
13461352
return x == value;
13471353
}

regression-tests/pure2-is-with-variable-and-value.cpp2

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
fun: (name, v) = {
2-
std::cout << name << ": " <<
2+
std::cout << name << ": " <<
33
inspect v -> std::string {
44
is (42) = "42";
55
is (123) = "op_is";
66
is (-123) = "generic op_is";
7-
is (4321) = "comperable";
7+
is (4321) = "comparable";
88
is ("text") = "text";
99
is _ = "unknown";
1010
}
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,118 @@
11
mixed-bugfix-for-ufcs-non-local.cpp2:13:12: error: a lambda expression cannot appear in this context
22
template<t<CPP2_UFCS_NONLOCAL(f)(o)> UnnamedTypeParam1_1> bool inline constexpr v0 = false;// Fails on GCC ([GCC109781][]) and Clang 12 (a lambda expression cannot appear in this context)
33
^
4-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
4+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
55
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
66
^
7-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
7+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
88
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
99
^
1010
mixed-bugfix-for-ufcs-non-local.cpp2:15:3: error: a lambda expression cannot appear in this context
1111
t<CPP2_UFCS_NONLOCAL(f)(o)> inline constexpr v1 = t<true>();// Fails on Clang 12 (lambda in unevaluated context).
1212
^
13-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
13+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
1414
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
1515
^
16-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
16+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
1717
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
1818
^
1919
mixed-bugfix-for-ufcs-non-local.cpp2:21:12: error: a lambda expression cannot appear in this context
2020
template<t<CPP2_UFCS_NONLOCAL(f)(o)> UnnamedTypeParam1_2> auto g() -> void;
2121
^
22-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
22+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
2323
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
2424
^
25-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
25+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
2626
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
2727
^
2828
mixed-bugfix-for-ufcs-non-local.cpp2:23:42: error: a lambda expression cannot appear in this context
2929
auto g([[maybe_unused]] cpp2::impl::in<t<CPP2_UFCS_NONLOCAL(f)(o)>> unnamed_param_1) -> void;
3030
^
31-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
31+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
3232
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
3333
^
34-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
34+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
3535
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
3636
^
3737
mixed-bugfix-for-ufcs-non-local.cpp2:27:29: error: a lambda expression cannot appear in this context
3838
[[nodiscard]] auto h() -> t<CPP2_UFCS_NONLOCAL(f)(o)>;
3939
^
40-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
40+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
4141
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
4242
^
43-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
43+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
4444
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
4545
^
4646
mixed-bugfix-for-ufcs-non-local.cpp2:31:12: error: a lambda expression cannot appear in this context
4747
template<t<CPP2_UFCS_NONLOCAL(f)(o)> UnnamedTypeParam1_3> using a = bool;// Fails on GCC ([GCC109781][]) and Clang 12 (a lambda expression cannot appear in this context)
4848
^
49-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
49+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
5050
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
5151
^
52-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
52+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
5353
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
5454
^
5555
mixed-bugfix-for-ufcs-non-local.cpp2:33:12: error: a lambda expression cannot appear in this context
5656
template<t<CPP2_UFCS_NONLOCAL(f)(o)> UnnamedTypeParam1_4> auto inline constexpr b = false;// Fails on GCC ([GCC109781][]).
5757
^
58-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
58+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
5959
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
6060
^
61-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
61+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
6262
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
6363
^
6464
mixed-bugfix-for-ufcs-non-local.cpp2:35:13: error: a lambda expression cannot appear in this context
6565
using c = t<CPP2_UFCS_NONLOCAL(f)(o)>;// Fails on Clang 12 (lambda in unevaluated context) and Clang 12 (a lambda expression cannot appear in this context)
6666
^
67-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
67+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
6868
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
6969
^
70-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
70+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
7171
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
7272
^
7373
mixed-bugfix-for-ufcs-non-local.cpp2:37:29: error: a lambda expression cannot appear in this context
7474
auto inline constexpr d = t<CPP2_UFCS_NONLOCAL(f)(o)>();// Fails on Clang 12 (lambda in unevaluated context).
7575
^
76-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
76+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
7777
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
7878
^
79-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
79+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
8080
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
8181
^
8282
mixed-bugfix-for-ufcs-non-local.cpp2:21:12: error: a lambda expression cannot appear in this context
8383
template<t<CPP2_UFCS_NONLOCAL(f)(o)> UnnamedTypeParam1_2> auto g() -> void{}// Fails on GCC ([GCC109781][]) and Clang 12 (a lambda expression cannot appear in this context)
8484
^
85-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
85+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
8686
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
8787
^
88-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
88+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
8989
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
9090
^
9191
mixed-bugfix-for-ufcs-non-local.cpp2:23:42: error: a lambda expression cannot appear in this context
9292
auto g([[maybe_unused]] cpp2::impl::in<t<CPP2_UFCS_NONLOCAL(f)(o)>> unnamed_param_1) -> void{}// Fails on Clang 12 (lambda in unevaluated context).
9393
^
94-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
94+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
9595
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
9696
^
97-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
97+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
9898
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
9999
^
100100
mixed-bugfix-for-ufcs-non-local.cpp2:27:29: error: a lambda expression cannot appear in this context
101101
[[nodiscard]] auto h() -> t<CPP2_UFCS_NONLOCAL(f)(o)> { return o; }// Fails on Clang 12 (lambda in unevaluated context).
102102
^
103-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
103+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
104104
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
105105
^
106-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
106+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
107107
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
108108
^
109109
mixed-bugfix-for-ufcs-non-local.cpp2:41:85: error: lambda expression in an unevaluated operand
110110
inline CPP2_CONSTEXPR bool u::c = [](cpp2::impl::in<std::type_identity_t<decltype(CPP2_UFCS_NONLOCAL(f)(o))>> x) mutable -> auto { return x; }(true);// Fails on Clang 12 (lambda in unevaluated context).
111111
^
112-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
112+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
113113
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
114114
^
115-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
115+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
116116
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
117117
^
118118
13 errors generated.

regression-tests/test-results/clang-12/mixed-inspect-values.cpp.execution

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ zero
99
3
1010
integer -42
1111
xyzzy
12-
3
12+
(no match)
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
pure2-bugfix-for-ufcs-noexcept.cpp2:5:26: error: lambda expression in an unevaluated operand
22
static_assert(noexcept(CPP2_UFCS(swap)(t(), t())));// Fails on Clang 12 (lambda in unevaluated context) and GCC 10 (static assertion failed)
33
^
4-
../../../include/cpp2util.h:988:59: note: expanded from macro 'CPP2_UFCS'
4+
../../../include/cpp2util.h:1107:59: note: expanded from macro 'CPP2_UFCS'
55
#define CPP2_UFCS(...) CPP2_UFCS_(&,CPP2_UFCS_EMPTY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
66
^
7-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
7+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
88
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
99
^
1010
1 error generated.
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
pure2-bugfix-for-ufcs-sfinae.cpp2:1:78: error: lambda expression in an unevaluated operand
22
template<typename T> [[nodiscard]] auto f() -> std::type_identity_t<decltype(CPP2_UFCS_NONLOCAL(a)(T()))>;
33
^
4-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
4+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
55
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
66
^
7-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
7+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
88
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
99
^
1010
pure2-bugfix-for-ufcs-sfinae.cpp2:1:78: error: lambda expression in an unevaluated operand
1111
template<typename T> [[nodiscard]] auto f() -> std::type_identity_t<decltype(CPP2_UFCS_NONLOCAL(a)(T()))>{}// Fails on Clang 12 (lambda in unevaluated context).
1212
^
13-
../../../include/cpp2util.h:993:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
13+
../../../include/cpp2util.h:1112:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
1414
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,CPP2_UFCS_IDENTITY,CPP2_UFCS_IDENTITY,(),,__VA_ARGS__)
1515
^
16-
../../../include/cpp2util.h:955:66: note: expanded from macro 'CPP2_UFCS_'
16+
../../../include/cpp2util.h:1074:66: note: expanded from macro 'CPP2_UFCS_'
1717
#define CPP2_UFCS_(LAMBDADEFCAPT,SFINAE,MVFWD,QUALID,TEMPKW,...) \
1818
^
1919
2 errors generated.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
3.140000 is double bigger than 3
2+
3.140000 is bigger than 3
3+
42 is integer bigger than 3
4+
42 is bigger than 3
5+
a is integer bigger than 3
6+
a is bigger than 3

regression-tests/test-results/clang-12/pure2-is-with-free-functions-predicate.cpp.output

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
3.140000 is double bigger than 3
2+
3.140000 is bigger than 3
3+
42 is integer bigger than 3
4+
42 is bigger than 3
5+
a is integer bigger than 3
6+
a is bigger than 3

regression-tests/test-results/clang-12/pure2-is-with-unnamed-predicates.cpp.output

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
3.14: unknown
2+
42: 42
3+
WithOp(): unknown
4+
WithGenOp(): unknown
5+
Cmp(): comparable
6+
std::string("text"): text
7+
"text": text
8+
std::string_view("text"): text
9+
:std::vector = ('t','e','x','t','\0'): unknown

regression-tests/test-results/clang-12/pure2-is-with-variable-and-value.cpp.output

Whitespace-only changes.

regression-tests/test-results/gcc-10/mixed-inspect-values.cpp.execution

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ zero
99
3
1010
integer -42
1111
xyzzy
12-
3
12+
(no match)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
3.140000 is double bigger than 3
2+
3.140000 is bigger than 3
3+
42 is integer bigger than 3
4+
42 is bigger than 3
5+
a is integer bigger than 3
6+
a is bigger than 3

regression-tests/test-results/gcc-10/pure2-is-with-free-functions-predicate.cpp.output

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
3.140000 is double bigger than 3
2+
3.140000 is bigger than 3
3+
42 is integer bigger than 3
4+
42 is bigger than 3
5+
a is integer bigger than 3
6+
a is bigger than 3

regression-tests/test-results/gcc-10/pure2-is-with-unnamed-predicates.cpp.output

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
3.14: unknown
2+
42: 42
3+
WithOp(): unknown
4+
WithGenOp(): unknown
5+
Cmp(): comparable
6+
std::string("text"): text
7+
"text": text
8+
std::string_view("text"): text
9+
:std::vector = ('t','e','x','t','\0'): unknown

regression-tests/test-results/gcc-10/pure2-is-with-variable-and-value.cpp.output

Whitespace-only changes.

regression-tests/test-results/gcc-13/gcc-version.output

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
g++ (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4)
1+
g++ (GCC) 13.2.1 20240316 (Red Hat 13.2.1-7)
22
Copyright (C) 2023 Free Software Foundation, Inc.
33
This is free software; see the source for copying conditions. There is NO
44
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

0 commit comments

Comments
 (0)