-
Notifications
You must be signed in to change notification settings - Fork 169
Add support for inplace_vector #1729
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
base: main
Are you sure you want to change the base?
Conversation
It works, but I'm not sure if it is worthy to be merged becouse:
|
Thanks for making this merge request! I do like the idea of inplace_vector support and this gives a starting point for experimenting with that support. I'll look into them when I get some time. I wouldn't mind merging in a solution that is 90% there and improving it over time. |
I will try to bring beman.inplace_vector into a somewhat usable state before continuing with this PR. If anyone knows of a good inplace_vector implementation that doesn’t require a full custom STL, please let me know :) |
@20162026, I walked AI through generating an |
@20162026, I think |
@stephenberry would you be interested in supporting deleting throwing/aborting functions is extremely convenient for embedded, as you get compiler warning instead of runtime error when trying to use potentially throwing functions. But it would require at least some minor concept changes as it will no longer be direct vector replacement. also as a sidenot, would you like me to add pre-commit for formatting? |
@20162026, yes I think 'freestanding-deleted' makes sense. Go ahead. And, per your side note about formatting, Glaze is actually setup to use clang-format (just upgraded to v20) automatically when the code gets merged, so don't worry about formatting this merge request. |
@stephenberry is there actually performance gain in release build when using stuff like if constexpr (std::is_trivially_copyable_v<T>) {
std::memcpy(this->data_ptr() + storage_size(), &x, sizeof(T));
}
else {
std::construct_at(this->data_ptr() + storage_size(), x);
} or if constexpr (std::is_trivially_copyable_v<T>) {
return std::memcmp(lhs.data_ptr(), rhs.data_ptr(), lhs.storage_size() * sizeof(T)) == 0;
}
else {
return std::equal(lhs.begin(), lhs.end(), rhs.begin());
} I would expect compiler to be smart enough to optmize such case for trivial types? |
@20162026, I fixed an issue with pop_back removing the wrong element, and I fixed some use of inplace_vector<T, 0>. After going through it again I think it is in a good place, and it really is mainly existing to test the concept usage in the rest of Glaze. Do you think it's in a good place to merge? |
I will redo concepts for inplace_vector detection, as freestanding inplace_vector might not fullfill current |
CI failed becouse security.ubuntu.com is dead xd, maybe try rerunning them when it is back up.... other than that, guess Im done with the changes for now |
@20162026, CI passed. |
hi @stephenberry, don't want to rush you or sound rude, but what is the state of this PR? would you like to see some changes or is it ok as is? |
I think it is in a good place. If you agree, I'll merge it in. |
ok, you can merge it |
#1676