Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Info.defaultInsertable #664

Conversation

HGuillemet
Copy link
Contributor

Add a new Info to hint that a class cannot be default-constructed in containers.

WIthout this PR, some containers cannot be mapped to Java because the Parser will generate a resize method that is not supported.

Seen in pytorch for things like std::vector<torch::OrderedDict<std::string,std::shared_ptr<torch::nn::Module>>::Item> or std::vector<torch::nn::AnyValue>.

@saudet
Copy link
Member

saudet commented Mar 23, 2023

I'm pretty sure that's already covered by prefixing the cppNames with "const" like those here: https://github.com/bytedeco/javacpp-presets/blob/master/pytorch/src/main/java/org/bytedeco/pytorch/presets/torch.java#L2118

@HGuillemet
Copy link
Contributor Author

Ah, I missed that.
Adding const does more than just skipping resize: it also skips put and erase, and replaces get by at, but it should do the trick for the current need in Pytorch.
You can put this PR on hold.

@HGuillemet HGuillemet closed this Jan 1, 2024
@HGuillemet HGuillemet deleted the valuetype_without_default_constructor branch January 1, 2024 23:55
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.

None yet

2 participants