operator& copies out of lvalue-reference payloads. On main, optional<int&> & optional<int> is optional<pack<int, int>> and optional<int&> & optional<long&> is optional<pack<int, long>>: each factor is the carrier's value_type, which is T for optional<T&>.
The change for #448 makes the disjunction keep reference payloads: optional<int&> | optional<long&> becomes optional<copack<int&, long&>>. After it, | and & treat the same operands differently. This issue asks whether & should also take its factors from the payload type, so that optional<int&> & optional<int> is optional<pack<int&, int>>.
For keeping references
For copying
- Appending a plain value to a product copies it:
as_pack(x) & y is pack<int&, long>. A reference enters a product only through an explicit lift, and a carrier operand could be read as a plain value.
Affected either way
The referent's cv-qualification leaks into the product: optional<int const&> & optional<long&> is optional<pack<int const, long>>. Keeping references gives pack<int const&, long>; copying should give pack<int, long>.
Assisted-by: Claude:claude-opus-5-5
operator&copies out of lvalue-reference payloads. Onmain,optional<int&> & optional<int>isoptional<pack<int, int>>andoptional<int&> & optional<long&>isoptional<pack<int, long>>: each factor is the carrier'svalue_type, which isTforoptional<T&>.The change for #448 makes the disjunction keep reference payloads:
optional<int&> | optional<long&>becomesoptional<copack<int&, long&>>. After it,|and&treat the same operands differently. This issue asks whether&should also take its factors from the payload type, so thatoptional<int&> & optional<int>isoptional<pack<int&, int>>.For keeping references
packadmits lvalue-reference elements, and lifting an lvalue keeps it: forint x,as_pack(x)ispack<int&>.copack#448, so both operators would agree on what a reference payload contributes.just<T&>(Support lvalue-reference payloads injust#437) follows whatever ruleoptional<T&>follows.For copying
as_pack(x) & yispack<int&, long>. A reference enters a product only through an explicit lift, and a carrier operand could be read as a plain value.Affected either way
The referent's cv-qualification leaks into the product:
optional<int const&> & optional<long&>isoptional<pack<int const, long>>. Keeping references givespack<int const&, long>; copying should givepack<int, long>.Assisted-by: Claude:claude-opus-5-5