Page MenuHomePhabricator

[Backport]Add some general std::vector utility functions
ClosedPublic

Authored by PiRK on Sep 21 2020, 20:32.

Details

Reviewers
majcosta
deadalnix
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
Commits
rABC8bcedbe15a84: [Backport]Add some general std::vector utility functions
Summary

Added are:

  • Vector(arg1,arg2,arg3,...) constructs a vector with the specified arguments as elements. The vector's type is derived from the arguments. If some of the arguments are rvalue references, they will be moved into place rather than copied (which can't be achieved using list initialization).
  • Cat(vector1,vector2) returns a concatenation of the two vectors, efficiently moving elements when relevant.

Vector generalizes (and replaces) the Singleton function in
src/descriptor.cpp, and Cat replaces the Cat function in bech32.cpp

Add tests for util/vector.h's Cat and Vector

Backport of Bitcoin Core PR16889

Test Plan

ninja && ninja check

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Owners added a reviewer: Restricted Owners Package.Sep 21 2020, 20:32
PiRK requested review of this revision.Sep 21 2020, 20:32

[Bot Message]
One or more PR numbers were detected in the summary.
Links to those PRs have been inserted into the summary for reference.

The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.
The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.
The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.
The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.
majcosta requested changes to this revision.Sep 21 2020, 21:59
majcosta added a subscriber: majcosta.

PR has changes to bech32.cpp which also need porting

src/test/util_tests.cpp
2195 ↗(On Diff #23638)

https://github.com/bitcoin/bitcoin/pull/17095 hasn't been done yet and would be around here-ish. might be a good followup to this.

src/util/vector.h
12 ↗(On Diff #23638)

please change the formatting to this:

/*
 * Construct a vector with the specified elements.
 ...
 */
31 ↗(On Diff #23638)

same throughout

This revision now requires changes to proceed.Sep 21 2020, 21:59

Regarding the style of the comments, should we update developer-notes.md accordingly? Is the style with a single * compatible with Doxygen?

apply bech32.cpp changes to cashaddr.cpp

This revision is now accepted and ready to land.Sep 22 2020, 14:05