Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Improve Container Types #180
base: master
Are you sure you want to change the base?
Improve Container Types #180
Changes from 1 commit
4756017
880f4bd
b6f4513
937f56d
6080dc9
00a2473
3ae9d42
9a904b4
ca50d24
52c2085
8d95b35
b837509
4a0fa19
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
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.
It could be done here for example
https://github.com/wopss/RED4ext.SDK/pull/180/files/937f56dff17f36dd9f21867b8d0947685f204709..6080dc94c662a07d0bc97bcc2834c5072fd7c2c2#r1951944671
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.
Is there a valid use case for this? I can't think of any, and you will have to handle special cases, such as
Map
.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.
I gave some of my reasons in discord, but yes I think so. Also the template using the
ContainerType
concept to enforce what exactly can be used here, so things likeMap
aren't a concern afaictThere 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.
Why not do something like:
?
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.
Because I have a habit of over-complicating things when I haven't slept :)
Thank you
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.
You dont have to use requires in that case, just
template <std::input_iterator InputIt>
is enough, maybe can be even included in the signature itself, getting rid of the template keyword alltogether if you do not need to do something with the type.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.
And looking at the code now, think you should be able to do just that.
DynArray(std::input_iterator auto aFirst, std::input_iterator auto aLast, Memory::IAllocator* aAllocator = nullptr)
Unsure if it is wanted to be passed by value though, need to look at the implementation in full finally... If you need to pass by reference in the simplified case, just put & after the auto in the above.
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.
You can actually do sth like that in multiple places from quick glance, you dont seem to be accessing the type explicitly in many of them. Using template keyword in such cases is a bit of a waste.
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.
Actually, rereading my comments, you may not want to do the simplified case without template in the end here as it would match 2 distinct input iterators on input... Still could be done in some other places.
This variant should be used here to ensure same type. #180 (comment)
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.
This is having a complexity of
O(n)
, Before it wasO(1)
, do the swap trick.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.
Assign should not
shrink_to_fit
.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.
No need for the check.
std::destory
is well defined in this case.This is more like a comment, not a request for change, so if you want feel free to keep it.