Skip to content

Handle explicit/deleted copy constructor and assignment#30

Open
slburson wants to merge 1 commit into
borodust:masterfrom
slburson:copy-ctor-and-assign
Open

Handle explicit/deleted copy constructor and assignment#30
slburson wants to merge 1 commit into
borodust:masterfrom
slburson:copy-ctor-and-assign

Conversation

@slburson

@slburson slburson commented Jul 1, 2026

Copy link
Copy Markdown

Claw generates setters for public fields of classes under certain conditions. Those conditions were too weakly specified, so that some of the generated setters were uncompilable. This happened when the type of the field was an unassignable class, which could happen for a few reasons (other than the obvious one of the field being declared const):

  • the class had a deleted copy assignment operator
  • the class had a reference-typed field
  • the class has an unassignable superclass (and does not have its own copy assignment operator)
  • the class is a template instantiation and one of the arguments is an unassignable class

I had to include the last possibility because Claw doesn't see the bodies of excluded templates; so the rule makes the reasonable assumption that a template with a class parameter will use the class as a field type or superclass. As such, it's a little bit heuristic, but I figure it's better not to generate a needed setter — it can always be added manually — than to generate an uncompilable one.

Similarly, there are cases where the generated adapter function needs to use std::move to pass a parameter, because the parameter's pointer target type is not copy-constructible.

For both of these, I've captured a little more information in libresect.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant