Skip to content

Commit

Permalink
Merge #2753: [Libs] Re-introduce immer header-only library as a git s…
Browse files Browse the repository at this point in the history
…ubtree

d454272 [Lint] Ignore src/immer in lint-whitespace.sh (Fuzzbawls)
751fd3f [GA] Lint src/immer with git-subtree-check.sh (Fuzzbawls)
35c0d52 Squashed 'src/immer/' content from commit abb2b02e34 (Fuzzbawls)
98eab06 [Cleanup] Remove immer sources in prep for subtreeing (Fuzzbawls)

Pull request description:

  Reintroduce the header-only immer library as a git subtree and bump the version to the latest v0.7.0 (commit 9cb6a5a845df766a4cb3526d8a4584bf99bac8d5).

  Since we only really want the header sources, this subtree is a bit different than our other subtrees. I've used `git subtree split` to extract out only the relevant `immer` path from the source repo, and then added that split out path as a git subtree. this method is documented at https://jrsmith3.github.io/merging-a-subdirectory-from-another-repo-via-git-subtree.html

  This ultimately allows us to lint that the `src/immer` path remains unchanged by manual commits, like any other 3rd party subtree library that we use (chiabls, crc32c, leveldb, secp256k1, univalue).

  I bumped the version of immer used so as to include a fix proposed by @codablock (arximboldi/immer#80), which was later merged upstream. this particular PR does not affect PIVX whatsoever, as we no longer ship 32-bit windows binaries, but v0.7.0 was officially released on Nov 8, 2021.

  Note to reviewers: best to view this with whitespace-only changes ignored.

ACKs for top commit:
  Liquid369:
    tACK d454272
  panleone:
    tACK d454272

Tree-SHA512: 6301a4d5a73a524b02794a1e7a1830406a39bd74338d7cb652346657367ab06c024f93a03fbca34c0015dbc0498b78552a224319f650d2f4f158671f2ada95a3
  • Loading branch information
Fuzzbawls committed Apr 4, 2023
2 parents 0d779aa + d454272 commit aa9be76
Show file tree
Hide file tree
Showing 58 changed files with 4,980 additions and 3,643 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
test/lint/git-subtree-check.sh src/leveldb
test/lint/git-subtree-check.sh src/crc32c
test/lint/git-subtree-check.sh src/chiabls
test/lint/git-subtree-check.sh src/immer
test/lint/check-doc.py
test/lint/logprint-scanner.py
test/lint/lint-all.sh
Expand Down
35 changes: 17 additions & 18 deletions src/immer/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include <algorithm>
#include <cassert>
#include <numeric>
#include <type_traits>

Expand Down Expand Up @@ -47,8 +48,8 @@ template <typename Iterator, typename Fn>
void for_each_chunk(const Iterator& first, const Iterator& last, Fn&& fn)
{
assert(&first.impl() == &last.impl());
first.impl().for_each_chunk(first.index(), last.index(),
std::forward<Fn>(fn));
first.impl().for_each_chunk(
first.index(), last.index(), std::forward<Fn>(fn));
}

template <typename T, typename Fn>
Expand Down Expand Up @@ -81,8 +82,8 @@ template <typename Iterator, typename Fn>
bool for_each_chunk_p(const Iterator& first, const Iterator& last, Fn&& fn)
{
assert(&first.impl() == &last.impl());
return first.impl().for_each_chunk_p(first.index(), last.index(),
std::forward<Fn>(fn));
return first.impl().for_each_chunk_p(
first.index(), last.index(), std::forward<Fn>(fn));
}

template <typename T, typename Fn>
Expand All @@ -97,7 +98,7 @@ bool for_each_chunk_p(const T* first, const T* last, Fn&& fn)
template <typename Range, typename T>
T accumulate(Range&& r, T init)
{
for_each_chunk(r, [&] (auto first, auto last) {
for_each_chunk(r, [&](auto first, auto last) {
init = std::accumulate(first, last, init);
});
return init;
Expand All @@ -106,7 +107,7 @@ T accumulate(Range&& r, T init)
template <typename Range, typename T, typename Fn>
T accumulate(Range&& r, T init, Fn fn)
{
for_each_chunk(r, [&] (auto first, auto last) {
for_each_chunk(r, [&](auto first, auto last) {
init = std::accumulate(first, last, init, fn);
});
return init;
Expand All @@ -119,7 +120,7 @@ T accumulate(Range&& r, T init, Fn fn)
template <typename Iterator, typename T>
T accumulate(Iterator first, Iterator last, T init)
{
for_each_chunk(first, last, [&] (auto first, auto last) {
for_each_chunk(first, last, [&](auto first, auto last) {
init = std::accumulate(first, last, init);
});
return init;
Expand All @@ -128,7 +129,7 @@ T accumulate(Iterator first, Iterator last, T init)
template <typename Iterator, typename T, typename Fn>
T accumulate(Iterator first, Iterator last, T init, Fn fn)
{
for_each_chunk(first, last, [&] (auto first, auto last) {
for_each_chunk(first, last, [&](auto first, auto last) {
init = std::accumulate(first, last, init, fn);
});
return init;
Expand All @@ -140,7 +141,7 @@ T accumulate(Iterator first, Iterator last, T init, Fn fn)
template <typename Range, typename Fn>
Fn&& for_each(Range&& r, Fn&& fn)
{
for_each_chunk(r, [&] (auto first, auto last) {
for_each_chunk(r, [&](auto first, auto last) {
for (; first != last; ++first)
fn(*first);
});
Expand All @@ -154,7 +155,7 @@ Fn&& for_each(Range&& r, Fn&& fn)
template <typename Iterator, typename Fn>
Fn&& for_each(Iterator first, Iterator last, Fn&& fn)
{
for_each_chunk(first, last, [&] (auto first, auto last) {
for_each_chunk(first, last, [&](auto first, auto last) {
for (; first != last; ++first)
fn(*first);
});
Expand All @@ -167,9 +168,8 @@ Fn&& for_each(Iterator first, Iterator last, Fn&& fn)
template <typename Range, typename OutIter>
OutIter copy(Range&& r, OutIter out)
{
for_each_chunk(r, [&] (auto first, auto last) {
out = std::copy(first, last, out);
});
for_each_chunk(
r, [&](auto first, auto last) { out = std::copy(first, last, out); });
return out;
}

Expand All @@ -180,7 +180,7 @@ OutIter copy(Range&& r, OutIter out)
template <typename InIter, typename OutIter>
OutIter copy(InIter first, InIter last, OutIter out)
{
for_each_chunk(first, last, [&] (auto first, auto last) {
for_each_chunk(first, last, [&](auto first, auto last) {
out = std::copy(first, last, out);
});
return out;
Expand All @@ -192,9 +192,8 @@ OutIter copy(InIter first, InIter last, OutIter out)
template <typename Range, typename Pred>
bool all_of(Range&& r, Pred p)
{
return for_each_chunk_p(r, [&] (auto first, auto last) {
return std::all_of(first, last, p);
});
return for_each_chunk_p(
r, [&](auto first, auto last) { return std::all_of(first, last, p); });
}

/*!
Expand All @@ -204,7 +203,7 @@ bool all_of(Range&& r, Pred p)
template <typename Iter, typename Pred>
bool all_of(Iter first, Iter last, Pred p)
{
return for_each_chunk_p(first, last, [&] (auto first, auto last) {
return for_each_chunk_p(first, last, [&](auto first, auto last) {
return std::all_of(first, last, p);
});
}
Expand Down
Loading

0 comments on commit aa9be76

Please sign in to comment.