Fix the definition of is_substitute and variant-related substitutability#50
Fix the definition of is_substitute and variant-related substitutability#50
is_substitute and variant-related substitutability#50Conversation
This comment has been minimized.
This comment has been minimized.
saki7
left a comment
There was a problem hiding this comment.
At first glance, I don't think this can work. Removing the variant_has_substitute check entirely from is_substitute means variant is never going to be considered on substitution check. If this PR is seemingly working, I suspect there are many unimplemented tests that should fail after this change. And if it is truly working, I suspect there's conflicting scenario on #42 because the only remaining parts which use variant_has_substitute is in move_to, which is heavily modified in that PR.
If it's truly not needed, please remove the forward declaration also.
Anyhow, this is a big change, and I need to see a clear description (written in English) that
- explains why
variant_has_substitutewas required in the old codebase and - why removing it does not break the semantics on the current codebase.
is_substitute
|
Simple test case: static_assert(is_substitute_v<int, iris::rvariant<int, std::string>>); |
|
Please add this test case too: struct X {};
struct Y {};
struct Z {};
iris::rvariant<Y, Z> from;
iris::rvariant<X, Y, Z> to;
x4::move_to(std::move(from), to); |
Is the motivation for |
To be honest I'm not sure, but either one of the below should pass: static_assert(is_substitute_v<int, iris::rvariant<int, std::string>>); // 1
static_assert(is_substitute_v<iris::rvariant<int, std::string>, int>); // 2If both fails, I think |
d83fdad to
05a03e5
Compare
|
Currently (on 7324a7b), following code passes: STATIC_CHECK(!x4::traits::is_substitute_v<iris::rvariant<int, double>, int>);
STATIC_CHECK( x4::traits::is_substitute_v<int, iris::rvariant<int, double>>);And now (on f2b5afb), the inverse passes: STATIC_CHECK( x4::traits::is_substitute_v<iris::rvariant<int, double>, int>);
STATIC_CHECK(!x4::traits::is_substitute_v<int, iris::rvariant<int, double>>);Both definitions of |
|
I'm planning to rename STATIC_CHECK(x4::traits::is_suitable_for_temporary_creation_for_v<int, int>); // OK, identical type
STATIC_CHECK( x4::traits::is_suitable_for_temporary_creation_for_v<int, iris::rvariant<int>>); // OK, parsed value can be assigned to variant directly
STATIC_CHECK(!x4::traits::is_suitable_for_temporary_creation_for_v<iris::rvariant<int>, int>); // ??
STATIC_CHECK( x4::traits::is_suitable_for_temporary_creation_for_v<int, iris::rvariant<int, double>>); // OK, parsed value can be assigned to variant directly
STATIC_CHECK(!x4::traits::is_suitable_for_temporary_creation_for_v<iris::rvariant<int, double>, int>); // ??, parsed value can be incompatibleIn the current code, the latter cases are not handled and we should decide what types can be "temporary storage" for specific types. P.S. STATIC_CHECK(x4::traits::is_suitable_for_temporary_creation_for_v<int, iris::rvariant<iris::rvariant<int>, double>); // ??This assertion fails currently because:
However, parsed |
|
I think the "substitutability" can be defined by |
is_substituteis_substitute and variant-related substitutability
This can't be implemented because |
|
@yaito3014 Can you show me the actual test case that illustrates the substitutability on complex types? I think we're having a hard time determining the goal of this problem because we don't have a clear vision on the actual parser behavior. The test case should include both the type-level test and parser-level tests. |
|
If we relax constraints of P.S. |
b2f333b to
bde2641
Compare
Remove variant-related check fromrevertedis_substitutevariant_has_substituteis_substituteand variant-related substitutabilityTodo
pass_attibute_as_is->pass_attribute_as_is