diff --git a/src/ripple/app/tx/impl/ApplyContext.cpp b/src/ripple/app/tx/impl/ApplyContext.cpp index 6d479c8bb8..8f3c16aad3 100644 --- a/src/ripple/app/tx/impl/ApplyContext.cpp +++ b/src/ripple/app/tx/impl/ApplyContext.cpp @@ -103,17 +103,16 @@ ApplyContext::checkInvariantsHelper( std::shared_ptr const& before, std::shared_ptr const& after) { - // Sean Parent for_each_argument trick - (void)std::array{ - {((std::get(checkers). - visitEntry(index, isDelete, before, after)), 0)...} - }; + (..., std::get(checkers).visitEntry(index, isDelete, before, after)); }); - // Sean Parent for_each_argument trick (a fold expression with `&&` - // would be really nice here when we move to C++-17) - std::array finalizers {{ - std::get(checkers).finalize(tx, result, fee, journal)...}}; + // Note: do not replace this logic with a `...&&` fold expression. + // The fold expression will only run until the first check fails (it + // short-circuits). While the logic is still correct, the log + // message won't be. Every failed invariant should write to the log, + // not just the first one. + std::array finalizers{ + {std::get(checkers).finalize(tx, result, fee, journal)...}}; // call each check's finalizer to see that it passes if (! std::all_of( finalizers.cbegin(), finalizers.cend(), diff --git a/src/test/csf/collectors.h b/src/test/csf/collectors.h index e330a70d4b..372c9ff02d 100644 --- a/src/test/csf/collectors.h +++ b/src/test/csf/collectors.h @@ -70,10 +70,7 @@ class Collectors E e, std::index_sequence) { - // Sean Parent for_each_argument trick (C++ fold expressions would be - // nice here) - (void)std::array{ - {((apply(std::get(cs), who, when, e)), 0)...}}; + (..., apply(std::get(cs), who, when, e)); } public: