@@ -1629,15 +1629,15 @@ auto value = 0;
1629
1629
CPP2_UFCS (require, m, CPP2_UFCS_0 (is_public, m) || CPP2_UFCS_0 (is_default_access, m),
1630
1630
" a union alternative cannot be protected or private" );
1631
1631
1632
- if ( CPP2_UFCS_0 (is_object , m)) {
1633
- auto mo { CPP2_UFCS_0 (as_object, m)};
1634
- CPP2_UFCS (require, mo, CPP2_UFCS_0 (empty, CPP2_UFCS_0 (initializer, mo)),
1635
- " a union alternative cannot have an initializer " );
1636
-
1637
- // Adding local variable 'e' to work around a Clang warning
1638
- value_member_info e {cpp2::as_<std::string>( CPP2_UFCS_0 (name, mo)), CPP2_UFCS_0 (type, mo), cpp2::as_<std::string>(value)};
1639
- CPP2_UFCS (push_back, alternatives, e);
1640
- }
1632
+ auto mo { CPP2_UFCS_0 (as_object , m)};
1633
+ CPP2_UFCS (require, mo, CPP2_UFCS_0 (empty, CPP2_UFCS_0 (initializer, mo)),
1634
+ " a union alternative cannot have an initializer " );
1635
+
1636
+ // Adding local variable 'e' to work around a Clang warning
1637
+ value_member_info e {cpp2::as_<std::string>( CPP2_UFCS_0 (name, mo)), CPP2_UFCS_0 (type, mo), cpp2::as_<std::string>(value)};
1638
+ CPP2_UFCS (push_back, alternatives, e);
1639
+
1640
+ CPP2_UFCS_0 (mark_for_removal_from_enclosing_type, mo);
1641
1641
} while (false ); ++value; }
1642
1642
}
1643
1643
@@ -1659,7 +1659,7 @@ auto value = 0;
1659
1659
#line 1115 "reflect.h2"
1660
1660
// 2. Replace: Erase the contents and replace with modified contents
1661
1661
1662
- CPP2_UFCS_0 (remove_all_members , t);
1662
+ CPP2_UFCS_0 (remove_marked_members , t);
1663
1663
{
1664
1664
std::string storage = " _storage: std::aligned_storage_t<cpp2::max( " ;
1665
1665
@@ -1686,21 +1686,21 @@ std::string comma = "";
1686
1686
1687
1687
// Provide discriminator
1688
1688
#line 1135 "reflect.h2"
1689
- CPP2_UFCS (add_member, t, " discriminator__ : " + cpp2::to_string (std::move (discriminator_type)) + " = -1;\n " );
1689
+ CPP2_UFCS (add_member, t, " _discriminator : " + cpp2::to_string (std::move (discriminator_type)) + " = -1;\n " );
1690
1690
1691
1691
// Add the alternatives: is_alternative, get_alternative, and set_alternative
1692
1692
for (
1693
1693
auto const & a : alternatives )
1694
1694
{
1695
- CPP2_UFCS (add_member, t, " is_" + cpp2::to_string (a.name ) + " : (this) -> bool = discriminator__ == " + cpp2::to_string (a.value ) + " ;\n " );
1695
+ CPP2_UFCS (add_member, t, " is_" + cpp2::to_string (a.name ) + " : (this) -> bool = _discriminator == " + cpp2::to_string (a.value ) + " ;\n " );
1696
1696
1697
- CPP2_UFCS (add_member, t, " " + cpp2::to_string (a.name ) + " : (this) -> forward _ = reinterpret_cast<* const " + cpp2::to_string (a.type ) + " >(_storage&)*;\n " );
1697
+ CPP2_UFCS (add_member, t, " " + cpp2::to_string (a.name ) + " : (this) -> forward " + cpp2::to_string (a. type ) + " = reinterpret_cast<* const " + cpp2::to_string (a.type ) + " >(_storage&)*;\n " );
1698
1698
1699
- CPP2_UFCS (add_member, t, " " + cpp2::to_string (a.name ) + " : (inout this) -> forward _ = reinterpret_cast<*" + cpp2::to_string (a.type ) + " >(_storage&)*;\n " );
1699
+ CPP2_UFCS (add_member, t, " " + cpp2::to_string (a.name ) + " : (inout this) -> forward " + cpp2::to_string (a. type ) + " = reinterpret_cast<*" + cpp2::to_string (a.type ) + " >(_storage&)*;\n " );
1700
1700
1701
- CPP2_UFCS (add_member, t, " set_" + cpp2::to_string (a.name ) + " : (inout this, value: " + cpp2::to_string (a.type ) + " ) = { if !is_" + cpp2::to_string (a.name ) + " () { destroy(); std::construct_at( reinterpret_cast<*" + cpp2::to_string (a.type ) + " >(_storage&), value); } else { reinterpret_cast<*" + cpp2::to_string (a.type ) + " >(_storage&)* = value; } discriminator__ = " + cpp2::to_string (a.value ) + " ; }\n " );
1701
+ CPP2_UFCS (add_member, t, " set_" + cpp2::to_string (a.name ) + " : (inout this, value: " + cpp2::to_string (a.type ) + " ) = { if !is_" + cpp2::to_string (a.name ) + " () { destroy(); std::construct_at( reinterpret_cast<*" + cpp2::to_string (a.type ) + " >(_storage&), value); } else { reinterpret_cast<*" + cpp2::to_string (a.type ) + " >(_storage&)* = value; } _discriminator = " + cpp2::to_string (a.value ) + " ; }\n " );
1702
1702
1703
- CPP2_UFCS (add_member, t, " set_" + cpp2::to_string (a.name ) + " : (inout this, forward args...: _) = { if !is_" + cpp2::to_string (a.name ) + " () { destroy(); std::construct_at( reinterpret_cast<*" + cpp2::to_string (a.type ) + " >(_storage&), args...); } else { reinterpret_cast<*" + cpp2::to_string (a.type ) + " >(_storage&)* = :" + cpp2::to_string (a.type ) + " = (args...); } discriminator__ = " + cpp2::to_string (a.value ) + " ; }\n " );
1703
+ CPP2_UFCS (add_member, t, " set_" + cpp2::to_string (a.name ) + " : (inout this, forward args...: _) = { if !is_" + cpp2::to_string (a.name ) + " () { destroy(); std::construct_at( reinterpret_cast<*" + cpp2::to_string (a.type ) + " >(_storage&), args...); } else { reinterpret_cast<*" + cpp2::to_string (a.type ) + " >(_storage&)* = :" + cpp2::to_string (a.type ) + " = (args...); } _discriminator = " + cpp2::to_string (a.value ) + " ; }\n " );
1704
1704
}
1705
1705
{
1706
1706
std::string destroy = " private destroy: (inout this) = {\n " ;
@@ -1711,7 +1711,7 @@ std::string destroy = " private destroy: (inout this) = {\n";
1711
1711
{
1712
1712
for (
1713
1713
auto const & a : alternatives ) {
1714
- destroy += " if discriminator__ == " + cpp2::to_string (a.value ) + " { std::destroy_at( reinterpret_cast<*" + cpp2::to_string (a.type ) + " >(_storage&) ); }\n " ;
1714
+ destroy += " if _discriminator == " + cpp2::to_string (a.value ) + " { std::destroy_at( reinterpret_cast<*" + cpp2::to_string (a.type ) + " >(_storage&) ); }\n " ;
1715
1715
}
1716
1716
1717
1717
destroy += " }\n " ;
0 commit comments