You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should & keep lvalue-reference payloads of optional<T&>? #449
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
pack admits lvalue-reference elements, and lifting an lvalue keeps it: for int x, as_pack(x) is pack<int&>.
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>.
Activity
Key `|` and `&` on the payload type, keeping lvalue-reference payloads