-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Remove ambiguity in construction of prevector #14030
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
Conversation
The call with this default argument is redundant with prevector(size_type).
|
Note the effective implementation of change_capacity(n);
_size += n;
fill(item_ptr(0), n); |
AkioNak
left a 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.
utACK
Note to reviewers: This pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
| } | ||
|
|
||
| explicit prevector(size_type n, const T& val = T()) : _size(0) { | ||
| explicit prevector(size_type n, const T& val) : _size(0) { |
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.
The explicit keyword is also redundant for constructions with >1 argument.
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.
Neat!
It's not really relevant here, but I'll expand on @Empact's comment because it's something I didn't know, maybe others will benefit as well.
Post c++11:
using ScriptType = prevector<28, unsigned char>;
ScriptType vec{1, 255}; // always works
vec = ScriptType{1, 255}; // always works
vec = {1, 255}; // only works if prevector's ctor is not explicit.caveat: the 3rd example above does not actually work because of prevector's templated iterator ctor, but that's unrelated.
|
utACK |
|
utACK 497e90c. For reference, with c++11, std::vector's matching constructor also removed its default argument and dropped the explicit qualifier. |
497e90c Remove default argument to prevector constructor to remove ambiguity (Ben Woosley) Pull request description: The call with this default argument is redundant with `prevector(size_type)` on line 251. Tree-SHA512: 4d22e6f4cd56e4b700596d7f5afc945ec6684636a94690fa16a1bbb34e4f53b6340f53a6c314fea213359426474125228ba7193388789f8a13308506358e92db
497e90c Remove default argument to prevector constructor to remove ambiguity (Ben Woosley) Pull request description: The call with this default argument is redundant with `prevector(size_type)` on line 251. Tree-SHA512: 4d22e6f4cd56e4b700596d7f5afc945ec6684636a94690fa16a1bbb34e4f53b6340f53a6c314fea213359426474125228ba7193388789f8a13308506358e92db
The call with this default argument is redundant with
prevector(size_type)on line 251.