-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid constraint recursion for expected<any, ...>
and expected<void, any>
#4013
Conversation
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, ...>)`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments that I'll test-and-push changes for. Thanks for jumping on this bug so fast!
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 think it's beneficial not to relocate
_Allow_unwrapping
here and inexpected<void, ...>
, as it is used closely after definition so its function can be more obvious. - These can also be private:
Line 351 in 6c69a73
struct _NODISCARD _GuardTy {
Line 363 in 6c69a73
static constexpr void _Reinit_expected(_First& _New_val, _Second& _Old_val, _Args&&... _Vals) noexcept(
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.