Skip to content

& fails to compile on a const pack with a reference element #450

Open

Description

@Bronek

For an lvalue fn::pack<int&> const p, p & y fails inside the operator instead of yielding pack<int&, long>:

#include <fn/algebra.hpp>

int main()
{
  int x = 1;
  long y = 2;
  fn::pack<int &> const p{x};
  auto r = p & y; // error: no matching member function for call to 'append'
}

Copying p gives a pack<int&> bound to x. & instead extends p through append, which receives each element as a const pack hands it out, int const&; that cannot bind the new product's int& element. The error is hard, not a substitution failure: requires(fn::pack<int &> const &l, long &r) { l & r; } fails the same way rather than answering false.

Reproduced on main (b617188) with gcc 16.2.1 and clang 22.1.8.

After #448, a const copack<int&> conjoins: the product binds the referent as the alternative declares it, as a copy would. A const pack<int&> should do the same.

Assisted-by: Claude:claude-opus-5-5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions