Avoid constraint recursion for expected<any, ...> and expected<void, any>#4013
Avoid constraint recursion for expected<any, ...> and expected<void, any>#4013StephanTLavavej merged 5 commits intomicrosoft:mainfrom
expected<any, ...> and expected<void, any>#4013Conversation
additional test#include<any>
#include<expected>
#include<functional>
using namespace std;
void test_A() {
using T = expected<any, int>;
T t1;
T t2{ move(t1) };
T t3{ t2 };
using U = expected<void, any>;
U u1;
U u2{ move(u1) };
U u3{ u2 };
}
using X = expected<any, int>;
X meow() {
return {};
}
void test_B() {
function<X()> f{ meow };
}
int main() {
test_A();
test_B();
} |
e6edb3c to
e156420
Compare
…ted<void, ...>)`
|
Thanks! @CaseyCarter I pushed a trivial stylistic change after you approved. |
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
| && !is_constructible_v<unexpected<_Err>, expected<_Uty, _UErr>&> // | ||
| && !is_constructible_v<unexpected<_Err>, expected<_Uty, _UErr>> // | ||
| && !is_constructible_v<unexpected<_Err>, const expected<_Uty, _UErr>&> // | ||
| && !is_constructible_v<unexpected<_Err>, const expected<_Uty, _UErr>>; |
There was a problem hiding this comment.
Sorry for my untimely reply; if it's late to make new pushes and these changes look ok, I will carry these changes to another pr.
|
I find another weird case... #include<any>
#include<expected>
using namespace std;
int main() {
using T = expected<any, int>;
using U = expected<int, int>;
T t{ U{} };
(void) any_cast<U>(t.value()); // not thrown, t.any contains U instead of int
} |
This is probably mandatory as |
|
Thanks for fixing this constraint recursion! 🔁 🛠️ 🎉 |
expected<any, ...> and expected<void, any> copyableexpected<any, ...> and expected<void, any>
Fixes #4011.