Browse Source

Merge #10193: scripted-diff: Remove #include <boost/foreach.hpp>

b1268a1 clang-format: Delete ForEachMacros (Jorge Timón)
5995735 scripted-diff: Remove #include <boost/foreach.hpp> (Jorge Timón)
3eff827 scripted-diff: Remove BOOST_REVERSE_FOREACH (Jorge Timón)
33aed5b Fix const_reverse_iterator constructor (pass const ptr) (Jorge Timón)
300851e Introduce src/reverse_iterator.hpp and include it... (Jorge Timón)

Tree-SHA512: df3405328e9602d0a433ac134ba59a5c9a6202ef64188df2f94a59b2ce58dec7c988b25d0671c7937de516a96b2e6daeb9d04c82fa363b616ee4cf6e9cb0fac6
0.15
Wladimir J. van der Laan 8 years ago
parent
commit
6dbcc74a0e
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
  1. 1
      src/.clang-format
  2. 1
      src/Makefile.am
  3. 1
      src/bench/coin_selection.cpp
  4. 1
      src/bloom.cpp
  5. 4
      src/checkpoints.cpp
  6. 1
      src/checkqueue.h
  7. 1
      src/core_write.cpp
  8. 1
      src/httprpc.cpp
  9. 1
      src/memusage.h
  10. 1
      src/net.h
  11. 5
      src/net_processing.cpp
  12. 1
      src/policy/policy.cpp
  13. 2
      src/prevector.h
  14. 1
      src/qt/addresstablemodel.cpp
  15. 1
      src/qt/recentrequeststablemodel.cpp
  16. 1
      src/qt/transactionrecord.cpp
  17. 1
      src/qt/walletmodel.cpp
  18. 39
      src/reverse_iterator.h
  19. 1
      src/rpc/net.cpp
  20. 1
      src/rpc/server.cpp
  21. 1
      src/script/ismine.cpp
  22. 1
      src/script/sign.cpp
  23. 1
      src/script/standard.cpp
  24. 1
      src/sync.cpp
  25. 1
      src/test/getarg_tests.cpp
  26. 1
      src/test/multisig_tests.cpp
  27. 5
      src/test/prevector_tests.cpp
  28. 1
      src/test/script_tests.cpp
  29. 1
      src/test/transaction_tests.cpp
  30. 1
      src/timedata.cpp
  31. 1
      src/torcontrol.cpp
  32. 3
      src/txmempool.cpp
  33. 3
      src/validation.cpp
  34. 1
      src/wallet/crypter.cpp
  35. 1
      src/wallet/db.cpp
  36. 1
      src/wallet/rpcdump.cpp
  37. 1
      src/wallet/test/accounting_tests.cpp
  38. 1
      src/wallet/walletdb.cpp

1
src/.clang-format

@ -23,7 +23,6 @@ ContinuationIndentWidth: 4
Cpp11BracedListStyle: true Cpp11BracedListStyle: true
DerivePointerAlignment: false DerivePointerAlignment: false
DisableFormat: false DisableFormat: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, BOOST_REVERSE_FOREACH ]
IndentCaseLabels: false IndentCaseLabels: false
IndentFunctionDeclarationAfterType: false IndentFunctionDeclarationAfterType: false
IndentWidth: 4 IndentWidth: 4

1
src/Makefile.am

@ -124,6 +124,7 @@ BITCOIN_CORE_H = \
pow.h \ pow.h \
protocol.h \ protocol.h \
random.h \ random.h \
reverse_iterator.h \
reverselock.h \ reverselock.h \
rpc/blockchain.h \ rpc/blockchain.h \
rpc/client.h \ rpc/client.h \

1
src/bench/coin_selection.cpp

@ -5,7 +5,6 @@
#include "bench.h" #include "bench.h"
#include "wallet/wallet.h" #include "wallet/wallet.h"
#include <boost/foreach.hpp>
#include <set> #include <set>
static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<COutput>& vCoins) static void addCoin(const CAmount& nValue, const CWallet& wallet, std::vector<COutput>& vCoins)

1
src/bloom.cpp

@ -14,7 +14,6 @@
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include <boost/foreach.hpp>
#define LN2SQUARED 0.4804530139182014246671025263266649717305529515945455 #define LN2SQUARED 0.4804530139182014246671025263266649717305529515945455
#define LN2 0.6931471805599453094172321214581765680755001343602552 #define LN2 0.6931471805599453094172321214581765680755001343602552

4
src/checkpoints.cpp

@ -6,12 +6,12 @@
#include "chain.h" #include "chain.h"
#include "chainparams.h" #include "chainparams.h"
#include "reverse_iterator.h"
#include "validation.h" #include "validation.h"
#include "uint256.h" #include "uint256.h"
#include <stdint.h> #include <stdint.h>
#include <boost/foreach.hpp>
namespace Checkpoints { namespace Checkpoints {
@ -19,7 +19,7 @@ namespace Checkpoints {
{ {
const MapCheckpoints& checkpoints = data.mapCheckpoints; const MapCheckpoints& checkpoints = data.mapCheckpoints;
BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints) for (const MapCheckpoints::value_type& i : reverse_iterate(checkpoints))
{ {
const uint256& hash = i.second; const uint256& hash = i.second;
BlockMap::const_iterator t = mapBlockIndex.find(hash); BlockMap::const_iterator t = mapBlockIndex.find(hash);

1
src/checkqueue.h

@ -10,7 +10,6 @@
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <boost/foreach.hpp>
#include <boost/thread/condition_variable.hpp> #include <boost/thread/condition_variable.hpp>
#include <boost/thread/mutex.hpp> #include <boost/thread/mutex.hpp>

1
src/core_write.cpp

@ -15,7 +15,6 @@
#include "utilmoneystr.h" #include "utilmoneystr.h"
#include "utilstrencodings.h" #include "utilstrencodings.h"
#include <boost/foreach.hpp>
std::string FormatScript(const CScript& script) std::string FormatScript(const CScript& script)
{ {

1
src/httprpc.cpp

@ -18,7 +18,6 @@
#include <stdio.h> #include <stdio.h>
#include <boost/algorithm/string.hpp> // boost::trim #include <boost/algorithm/string.hpp> // boost::trim
#include <boost/foreach.hpp>
/** WWW-Authenticate to present with 401 Unauthorized response */ /** WWW-Authenticate to present with 401 Unauthorized response */
static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\""; static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\"";

1
src/memusage.h

@ -15,7 +15,6 @@
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
#include <boost/foreach.hpp>
namespace memusage namespace memusage
{ {

1
src/net.h

@ -33,7 +33,6 @@
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#include <boost/foreach.hpp>
#include <boost/signals2/signal.hpp> #include <boost/signals2/signal.hpp>
class CScheduler; class CScheduler;

5
src/net_processing.cpp

@ -22,6 +22,7 @@
#include "primitives/block.h" #include "primitives/block.h"
#include "primitives/transaction.h" #include "primitives/transaction.h"
#include "random.h" #include "random.h"
#include "reverse_iterator.h"
#include "tinyformat.h" #include "tinyformat.h"
#include "txmempool.h" #include "txmempool.h"
#include "ui_interface.h" #include "ui_interface.h"
@ -827,7 +828,7 @@ void PeerLogicValidation::UpdatedBlockTip(const CBlockIndex *pindexNew, const CB
// Relay inventory, but don't relay old inventory during initial block download. // Relay inventory, but don't relay old inventory during initial block download.
connman->ForEachNode([nNewHeight, &vHashes](CNode* pnode) { connman->ForEachNode([nNewHeight, &vHashes](CNode* pnode) {
if (nNewHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 0)) { if (nNewHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 0)) {
BOOST_REVERSE_FOREACH(const uint256& hash, vHashes) { for (const uint256& hash : reverse_iterate(vHashes)) {
pnode->PushBlockHash(hash); pnode->PushBlockHash(hash);
} }
} }
@ -2338,7 +2339,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
} else { } else {
std::vector<CInv> vGetData; std::vector<CInv> vGetData;
// Download as much as possible, from earliest to latest. // Download as much as possible, from earliest to latest.
BOOST_REVERSE_FOREACH(const CBlockIndex *pindex, vToFetch) { for (const CBlockIndex *pindex : reverse_iterate(vToFetch)) {
if (nodestate->nBlocksInFlight >= MAX_BLOCKS_IN_TRANSIT_PER_PEER) { if (nodestate->nBlocksInFlight >= MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
// Can't download any more from this peer // Can't download any more from this peer
break; break;

1
src/policy/policy.cpp

@ -13,7 +13,6 @@
#include "util.h" #include "util.h"
#include "utilstrencodings.h" #include "utilstrencodings.h"
#include <boost/foreach.hpp>
CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFeeIn) CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFeeIn)
{ {

2
src/prevector.h

@ -132,7 +132,7 @@ public:
typedef const T* pointer; typedef const T* pointer;
typedef const T& reference; typedef const T& reference;
typedef std::bidirectional_iterator_tag iterator_category; typedef std::bidirectional_iterator_tag iterator_category;
const_reverse_iterator(T* ptr_) : ptr(ptr_) {} const_reverse_iterator(const T* ptr_) : ptr(ptr_) {}
const_reverse_iterator(reverse_iterator x) : ptr(&(*x)) {} const_reverse_iterator(reverse_iterator x) : ptr(&(*x)) {}
const T& operator*() const { return *ptr; } const T& operator*() const { return *ptr; }
const T* operator->() const { return ptr; } const T* operator->() const { return ptr; }

1
src/qt/addresstablemodel.cpp

@ -10,7 +10,6 @@
#include "base58.h" #include "base58.h"
#include "wallet/wallet.h" #include "wallet/wallet.h"
#include <boost/foreach.hpp>
#include <QFont> #include <QFont>
#include <QDebug> #include <QDebug>

1
src/qt/recentrequeststablemodel.cpp

@ -11,7 +11,6 @@
#include "clientversion.h" #include "clientversion.h"
#include "streams.h" #include "streams.h"
#include <boost/foreach.hpp>
RecentRequestsTableModel::RecentRequestsTableModel(CWallet *wallet, WalletModel *parent) : RecentRequestsTableModel::RecentRequestsTableModel(CWallet *wallet, WalletModel *parent) :
QAbstractTableModel(parent), walletModel(parent) QAbstractTableModel(parent), walletModel(parent)

1
src/qt/transactionrecord.cpp

@ -12,7 +12,6 @@
#include <stdint.h> #include <stdint.h>
#include <boost/foreach.hpp>
/* Return positive answer if transaction should be shown in list. /* Return positive answer if transaction should be shown in list.
*/ */

1
src/qt/walletmodel.cpp

@ -34,7 +34,6 @@
#include <QSet> #include <QSet>
#include <QTimer> #include <QTimer>
#include <boost/foreach.hpp>
WalletModel::WalletModel(const PlatformStyle *platformStyle, CWallet *_wallet, OptionsModel *_optionsModel, QObject *parent) : WalletModel::WalletModel(const PlatformStyle *platformStyle, CWallet *_wallet, OptionsModel *_optionsModel, QObject *parent) :
QObject(parent), wallet(_wallet), optionsModel(_optionsModel), addressTableModel(0), QObject(parent), wallet(_wallet), optionsModel(_optionsModel), addressTableModel(0),

39
src/reverse_iterator.h

@ -0,0 +1,39 @@
// Taken from https://gist.github.com/arvidsson/7231973
#ifndef BITCOIN_REVERSE_ITERATOR_HPP
#define BITCOIN_REVERSE_ITERATOR_HPP
/**
* Template used for reverse iteration in C++11 range-based for loops.
*
* std::vector<int> v = {1, 2, 3, 4, 5};
* for (auto x : reverse_iterate(v))
* std::cout << x << " ";
*/
template <typename T>
class reverse_range
{
T &x;
public:
reverse_range(T &x) : x(x) {}
auto begin() const -> decltype(this->x.rbegin())
{
return x.rbegin();
}
auto end() const -> decltype(this->x.rend())
{
return x.rend();
}
};
template <typename T>
reverse_range<T> reverse_iterate(T &x)
{
return reverse_range<T>(x);
}
#endif // BITCOIN_REVERSE_ITERATOR_HPP

1
src/rpc/net.cpp

@ -19,7 +19,6 @@
#include "utilstrencodings.h" #include "utilstrencodings.h"
#include "version.h" #include "version.h"
#include <boost/foreach.hpp>
#include <univalue.h> #include <univalue.h>

1
src/rpc/server.cpp

@ -17,7 +17,6 @@
#include <univalue.h> #include <univalue.h>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/foreach.hpp>
#include <boost/signals2/signal.hpp> #include <boost/signals2/signal.hpp>
#include <boost/algorithm/string/case_conv.hpp> // for to_upper() #include <boost/algorithm/string/case_conv.hpp> // for to_upper()
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>

1
src/script/ismine.cpp

@ -11,7 +11,6 @@
#include "script/standard.h" #include "script/standard.h"
#include "script/sign.h" #include "script/sign.h"
#include <boost/foreach.hpp>
typedef std::vector<unsigned char> valtype; typedef std::vector<unsigned char> valtype;

1
src/script/sign.cpp

@ -12,7 +12,6 @@
#include "script/standard.h" #include "script/standard.h"
#include "uint256.h" #include "uint256.h"
#include <boost/foreach.hpp>
typedef std::vector<unsigned char> valtype; typedef std::vector<unsigned char> valtype;

1
src/script/standard.cpp

@ -10,7 +10,6 @@
#include "util.h" #include "util.h"
#include "utilstrencodings.h" #include "utilstrencodings.h"
#include <boost/foreach.hpp>
typedef std::vector<unsigned char> valtype; typedef std::vector<unsigned char> valtype;

1
src/sync.cpp

@ -9,7 +9,6 @@
#include <stdio.h> #include <stdio.h>
#include <boost/foreach.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#ifdef DEBUG_LOCKCONTENTION #ifdef DEBUG_LOCKCONTENTION

1
src/test/getarg_tests.cpp

@ -9,7 +9,6 @@
#include <vector> #include <vector>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
BOOST_FIXTURE_TEST_SUITE(getarg_tests, BasicTestingSetup) BOOST_FIXTURE_TEST_SUITE(getarg_tests, BasicTestingSetup)

1
src/test/multisig_tests.cpp

@ -14,7 +14,6 @@
#include "test/test_bitcoin.h" #include "test/test_bitcoin.h"
#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
typedef std::vector<unsigned char> valtype; typedef std::vector<unsigned char> valtype;

5
src/test/prevector_tests.cpp

@ -5,6 +5,7 @@
#include <vector> #include <vector>
#include "prevector.h" #include "prevector.h"
#include "reverse_iterator.h"
#include "serialize.h" #include "serialize.h"
#include "streams.h" #include "streams.h"
@ -56,13 +57,13 @@ class prevector_tester {
for (const T& v : pre_vector) { for (const T& v : pre_vector) {
local_check(v == real_vector[pos++]); local_check(v == real_vector[pos++]);
} }
BOOST_REVERSE_FOREACH(const T& v, pre_vector) { for (const T& v : reverse_iterate(pre_vector)) {
local_check(v == real_vector[--pos]); local_check(v == real_vector[--pos]);
} }
for (const T& v : const_pre_vector) { for (const T& v : const_pre_vector) {
local_check(v == real_vector[pos++]); local_check(v == real_vector[pos++]);
} }
BOOST_REVERSE_FOREACH(const T& v, const_pre_vector) { for (const T& v : reverse_iterate(const_pre_vector)) {
local_check(v == real_vector[--pos]); local_check(v == real_vector[--pos]);
} }
CDataStream ss1(SER_DISK, 0); CDataStream ss1(SER_DISK, 0);

1
src/test/script_tests.cpp

@ -24,7 +24,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <univalue.h> #include <univalue.h>

1
src/test/transaction_tests.cpp

@ -27,7 +27,6 @@
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
#include <boost/foreach.hpp>
#include <univalue.h> #include <univalue.h>

1
src/timedata.cpp

@ -15,7 +15,6 @@
#include "utilstrencodings.h" #include "utilstrencodings.h"
#include "warnings.h" #include "warnings.h"
#include <boost/foreach.hpp>
static CCriticalSection cs_nTimeOffset; static CCriticalSection cs_nTimeOffset;
static int64_t nTimeOffset = 0; static int64_t nTimeOffset = 0;

1
src/torcontrol.cpp

@ -17,7 +17,6 @@
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/signals2/signal.hpp> #include <boost/signals2/signal.hpp>
#include <boost/foreach.hpp>
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>

3
src/txmempool.cpp

@ -11,6 +11,7 @@
#include "validation.h" #include "validation.h"
#include "policy/policy.h" #include "policy/policy.h"
#include "policy/fees.h" #include "policy/fees.h"
#include "reverse_iterator.h"
#include "streams.h" #include "streams.h"
#include "timedata.h" #include "timedata.h"
#include "util.h" #include "util.h"
@ -127,7 +128,7 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256> &vHashes
// This maximizes the benefit of the descendant cache and guarantees that // This maximizes the benefit of the descendant cache and guarantees that
// setMemPoolChildren will be updated, an assumption made in // setMemPoolChildren will be updated, an assumption made in
// UpdateForDescendants. // UpdateForDescendants.
BOOST_REVERSE_FOREACH(const uint256 &hash, vHashesToUpdate) { for (const uint256 &hash : reverse_iterate(vHashesToUpdate)) {
// we cache the in-mempool children to avoid duplicate updates // we cache the in-mempool children to avoid duplicate updates
setEntries setChildren; setEntries setChildren;
// calculate children from mapNextTx // calculate children from mapNextTx

3
src/validation.cpp

@ -24,6 +24,7 @@
#include "primitives/block.h" #include "primitives/block.h"
#include "primitives/transaction.h" #include "primitives/transaction.h"
#include "random.h" #include "random.h"
#include "reverse_iterator.h"
#include "script/script.h" #include "script/script.h"
#include "script/sigcache.h" #include "script/sigcache.h"
#include "script/standard.h" #include "script/standard.h"
@ -2340,7 +2341,7 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
nHeight = nTargetHeight; nHeight = nTargetHeight;
// Connect new blocks. // Connect new blocks.
BOOST_REVERSE_FOREACH(CBlockIndex *pindexConnect, vpindexToConnect) { for (CBlockIndex *pindexConnect : reverse_iterate(vpindexToConnect)) {
if (!ConnectTip(state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : std::shared_ptr<const CBlock>(), connectTrace, disconnectpool)) { if (!ConnectTip(state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : std::shared_ptr<const CBlock>(), connectTrace, disconnectpool)) {
if (state.IsInvalid()) { if (state.IsInvalid()) {
// The block violates a consensus rule. // The block violates a consensus rule.

1
src/wallet/crypter.cpp

@ -12,7 +12,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <boost/foreach.hpp>
int CCrypter::BytesToKeySHA512AES(const std::vector<unsigned char>& chSalt, const SecureString& strKeyData, int count, unsigned char *key,unsigned char *iv) const int CCrypter::BytesToKeySHA512AES(const std::vector<unsigned char>& chSalt, const SecureString& strKeyData, int count, unsigned char *key,unsigned char *iv) const
{ {

1
src/wallet/db.cpp

@ -18,7 +18,6 @@
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
#include <boost/foreach.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
// //

1
src/wallet/rpcdump.cpp

@ -26,7 +26,6 @@
#include <univalue.h> #include <univalue.h>
#include <boost/foreach.hpp>
std::string static EncodeDumpTime(int64_t nTime) { std::string static EncodeDumpTime(int64_t nTime) {
return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime); return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime);

1
src/wallet/test/accounting_tests.cpp

@ -8,7 +8,6 @@
#include <stdint.h> #include <stdint.h>
#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
extern CWallet* pwalletMain; extern CWallet* pwalletMain;

1
src/wallet/walletdb.cpp

@ -18,7 +18,6 @@
#include <atomic> #include <atomic>
#include <boost/foreach.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
// //

Loading…
Cancel
Save