-
Notifications
You must be signed in to change notification settings - Fork 95
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
Static vector #1622
Static vector #1622
Conversation
af15d43
to
c2fd425
Compare
One open question; can I forward template<typename Range>
constexpr static_vector(from_range_t, Range&& range) {
for (auto&& elem : range) {
- push_back(elem);
+ push_back(std::forward<T>(elem));
}
} Originally I thought I could Then I thought maybe I should do |
This is indeed a bit tricky. And what makes this even more difficult is that Sonarcloud generates some false-positive warnings in this area. Usually I just follow some rule-of-thumbs and then stuff just works. But since you ask I'll try to reconstruct the underlying C++ rules (and I learned some new things myself while doing this). There are two separate issues. How to pass the
Unfortunately Sonarcloud does not agree with this rule. But I double checked this with the advice given in some c++ book I read (I think it was https://cppstd20.com/ the section about ranges and views).
Using a variable by-name always gives an l-value. With So in this specific example we need to know the type of the
Feel free to make this change in the code. Here is the experiment I did to verify some of the above information: https://godbolt.org/z/az1zxY1vr |
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.
static_vector: Expand implementation.
Looks good.
I assume you need (some of) this in a later patch? Possible because you use it in combination with view::take()
?
Background info:
The intention is that in the future we replace our static_vector
with a c++ standard implementation. The proposal is being discussed here: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p0843r11.html (the original name was also static_vector
, later it was renamed to inplace_vector
).
The serialisation needed
Would be great to have in the standard library indeed. |
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.
serialize_stl: Support static_vector serialisation.
Loading has a bug, see below.
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.
AmdFlash: Use static_vector to store command list.
Only some comments about small tweaks or suggestions (feel free to ignore).
And one comment about loading status
in case of an old savestate.
Review comments addressed, and issue fixed in |
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.
Since you mentioned a bug fix in this class (which I overlooked in my first review), I did a 2nd review. I found another bug, but maybe we shouldn't fix it? (instead we can accept a limitation).
9bdffed
to
97e6542
Compare
To have more of the common collection methods.
Also already add a dummy “status” field for use in a later commit.
Hi Wouter,
Here’s a spin-off from pull request #1620 where I expand the implementation of static_vector, add serialization support and use it to store the AmdFlash command list. Also already adds a dummy “status” field for use later.