The call with this default argument is redundant with prevector(size_type) on line 251.
Remove ambiguity in construction of prevector #14030
pull Empact wants to merge 1 commits into bitcoin:master from Empact:ambiguous-prevector-constructor changing 1 files +1 −1-
Empact commented at 10:00 AM on August 23, 2018: member
-
497e90c02b
Remove default argument to prevector constructor to remove ambiguity
The call with this default argument is redundant with prevector(size_type).
- fanquake added the label Refactoring on Aug 23, 2018
- Empact renamed this:
Remove default argument to prevector constructor to remove ambiguity
Remove ambiguity in construction of prevector
on Aug 23, 2018 -
Empact commented at 10:35 AM on August 23, 2018: member
Note the effective implementation of
resize(n)in this case is:change_capacity(n); _size += n; fill(item_ptr(0), n); - AkioNak approved
-
AkioNak commented at 10:57 AM on August 23, 2018: contributor
utACK
-
DrahtBot commented at 11:28 AM on August 23, 2018: member
<!--e57a25ab6845829454e8d69fc972939a-->Note to reviewers: This pull request conflicts with the following ones:
- #14028 (Explicitly initialize prevector _union by Empact)
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.
-
in src/prevector.h:255 in 497e90c02b
251 | @@ -252,7 +252,7 @@ class prevector { 252 | resize(n); 253 | } 254 | 255 | - explicit prevector(size_type n, const T& val = T()) : _size(0) { 256 | + explicit prevector(size_type n, const T& val) : _size(0) {
sipa commented at 4:26 PM on August 23, 2018:The
explicitkeyword is also redundant for constructions with >1 argument.
Empact commented at 4:49 PM on August 23, 2018:FYI: looks like this will change post C++11: https://en.cppreference.com/w/cpp/language/explicit https://en.cppreference.com/w/cpp/language/converting_constructor
theuni commented at 6:05 PM on August 23, 2018: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.
sipa commented at 4:26 PM on August 23, 2018: memberutACK
theuni commented at 6:11 PM on August 23, 2018: memberutACK 497e90c02b96e8739e8faf3d43e41ba1ff0627b7.
For reference, with c++11, std::vector's matching constructor also removed its default argument and dropped the explicit qualifier.
laanwj merged this on Aug 27, 2018laanwj closed this on Aug 27, 2018laanwj referenced this in commit 4a1a2148f6 on Aug 27, 2018PastaPastaPasta referenced this in commit 50a08e7ad7 on Jun 27, 2021PastaPastaPasta referenced this in commit 5729b7b84a on Jun 28, 2021PastaPastaPasta referenced this in commit bd09fb3ae4 on Jun 29, 2021PastaPastaPasta referenced this in commit 1843687f45 on Jun 29, 2021PastaPastaPasta referenced this in commit 32dc57486c on Jun 29, 2021PastaPastaPasta referenced this in commit c0d7a261c4 on Jun 29, 2021PastaPastaPasta referenced this in commit de43330181 on Jun 29, 2021Munkybooty referenced this in commit 19d78e8757 on Jun 30, 2021Munkybooty referenced this in commit 1d6003de86 on Jul 1, 2021PastaPastaPasta referenced this in commit 5773399cc3 on Jul 1, 2021MarcoFalke locked this on Sep 8, 2021
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 18:15 UTC
More mirrored repositories can be found on mirror.b10c.me