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 support for initializer_list on arrays #23309
Conversation
1312594
to
ab2c67b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I definitely agree that we need to do something here, but I was thinking of doing this "something" at wxArrayStringsAdapter
level, see #23036, and I'm not sure which approach is better, but they're probably mutually exclusive as we'd have ambiguous overloads if we implemented both proposals.
One advantage of this one is that it can indeed be done even in 3.2 as it's backwards compatible. And, to be honest, I don't see any problems with it.
Thank you for the first level of review, that’s really appreciated. |
I think the main advantage of So, even after thinking about it, I don't really see any problems with doing it like this and I think we should go ahead and do it in master for now and then, if we don't find any problems in practice neither, backport it to 3.2. Of course, the CI builds need to be fixed first -- could you please look at the errors in them? TIA! |
8cfdc7b
to
ef0a491
Compare
Annoyingly, it looks like this doesn't compile in STL build (see the failing CI builds). I didn't yet have time to look at this, do you already see a way to fix it there? |
ef0a491
to
2df6bad
Compare
In some cases the compiler fails to infer the template parameters in the |
It worked :) The trick was to call the base constructor with iterators. |
Looks good, thanks! I'll merge this in master soon. For 3.2 we'll need to add |
Sure, let me know if there's anything more I can do to help on this, or if you need me to do the PR on 3.2. |
While these array classes are deprecated in the user code, they're still used, for compatibility, in many places in wxWidgets API and allowing to create them from initializer_list makes using it more ergonomic as it's now possible to just pass an initializer list of items to fill the control with, for example, instead of appending them one by one. Closes wxWidgets#23309.
Sorry for completely forgetting to reply to this but a PR for 3.2 would indeed be nice. There we still need to test whether we're using C++11 at all but, AFAICS, we don't need TIA! |
While these array classes are deprecated in the user code, they're still used, for compatibility, in many places in wxWidgets API and allowing to create them from initializer_list makes using it more ergonomic as it's now possible to just pass an initializer list of items to fill the control with, for example, instead of appending them one by one. Ref wxWidgets#23309.
While these array classes are deprecated in the user code, they're still used, for compatibility, in many places in wxWidgets API and allowing to create them from initializer_list makes using it more ergonomic as it's now possible to just pass an initializer list of items to fill the control with, for example, instead of appending them one by one. This is the equivalent of 4d62df4 (Add support for initializer_list to wx dynamic arrays, 2023-03-02) from master. See #23309. Closes #23966.
Hi! I'm the nixpkgs maintainer for Tenacity, which uses wxGTK. This initializer_list work came to my attention via NixOS/nixpkgs#266945 (comment) From preliminary investigation, it appears that this change is responsible for breaking at least Tenacity and Audacity. I think it's a good change and should be kept. I've already prepared a fix on the Tenacity side of things and will be driving the process to get it upstreamed. Therefore, I'm not making any sort of request from you, I'm just giving you a heads up because I thought you'd like to know, in case it bears on any other planned changes or anything. |
@IreneKnapp Thanks for reporting this and sorry for breaking it. I am not sure what exactly is the problem in {Tena,Auda}city is, but I guess there is some new overload ambiguity? It looks like we really can't do any changes in 3.2 headers without breaking something :-( Not sure what to do about it, ideal would be to at least test the changes before the release, but we've never managed to do this. Again, I'd invite all maintainers of the packages using wx to monitor the project communications (we could create a special ultra low traffic mailing list for this or maybe post pre-release announcements to the existing wx-announce too) and help us with discovering such problems before the release. TIA! |
yeah there was a place where it uses list initialization and it used to fall back to a copy constructor because there was no initializer list support, but now it tries to use list initialization and gets an error because the parameter it's passing is a const reference and it used to get implicitly copied but now it doesn't, so there's no appropriate method to handle it and there was another place where it's using an overloaded assignment operator and now there's more options for what it could be so it's ambiguous, as you suggested. I'll add a link to the Tenacity PR sometime today so you can see the details. if you start a list like that I'll join it, I can't promise to read everything. please do let me know if us nix people can help in some way, nix is really good at rebuilding downstream stuff after changes, that has to be useful for testing somehow... |
I'm told upstream has fixed this; anyway here's my changes that show where the problems were - NixOS/nixpkgs#266945 (comment) |
Thanks for the explanations! I should have thought of this and kept the new ctor(s) inside some As for the list, I've asked whether a new one or posting to the existing wx-announce one would be preferable. If you have any preferences here, please let me know (here or by replying on wx-dev). For now I'm leaning towards just reusing the existing list to avoid creating too many of them. |
no preference here, the announce list does make sense to me. |
wxWidgets has introduced a breaking API change with wxWidgets/wxWidgets#23309 This issues is also discussed here: NixOS/nixpkgs#266945 (comment)
wxWidgets has introduced a breaking API change with wxWidgets/wxWidgets#23309 This issues is also discussed here: NixOS/nixpkgs#266945 (comment)
note that it'd be nice if i could subscribe to the announcements without having to involve a google account |
@evils I don't think you need a Google account to subscribe to the mailing list, at least not if you do it via email, i.e. send a request to wx-announce+subscribe@googlegroups.com. If this doesn't work for you, please contact me and we'll try to figure this out (although dealing with Google groups is difficult...). |
@vadz reviewing the KiCad devlist subscription email, maybe i did link it to my google account... joining does have an option to uncheck "link to my google profile" |
@evils Unfortunately I can confirm that it doesn't work, I've tested it by posting an email to subscribe from a unique address and got a reply directing me to https://groups.google.com/group/wx-announce/subscribe where I can't do anything. I don't see anything I can do about this in the group options neither, unfortunately. I can only suggest that you contact me by email and I try adding your email to the list directly, I think this might work but I'm not even sure about any more. Sorry. |
That definitely does work. I maintain a Google Group for something unrelated and the administrative interface does allow you to add non-Google users manually. They users can't access the web interface (eg, archives) though. |
Hello,
Class
wxArrayString
is used all throughout the project in many different components. This pull-requests intends to improve the developer experience by adding support forstd::initializer_list
and syntactic sugar to simplify the initialization ofwxArrayString
and other arrays.Exemple:
I wasn't sure about adding a constructor based on
std::vector<std::string>
or more generallystd::vector<T>
too. Any suggestions about this are welcome.