-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactor: Replace boost::bind with std::bind #13743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Concept ACK After this |
Concept ACK, but please remove See developer notes:
|
Those instances cannot be replaced simply
Will do |
I believe it is acceptable to be using |
@MarcoFalke I'm not sure I agree. The verbosity could help remind us that we really should use lambdas where we're currently using |
@practicalswift Since @MarcoFalke think that |
@ken2812221 OK! :-) Could you try rewriting them as lambdas where appropriate? That would get rid of |
@practicalswift Good point! I'll try to use lambda to replace bind |
src/rpc/server.cpp
Outdated
@@ -508,9 +507,10 @@ std::vector<std::string> CRPCTable::listCommands() const | |||
std::vector<std::string> commandList; | |||
typedef std::map<std::string, const CRPCCommand*> commandMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can remove, this is now unreferenced
How about |
src/validationinterface.cpp
Outdated
connections.Broadcast = g_signals.m_internals->Broadcast.connect(std::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1, _2)); | ||
connections.BlockChecked = g_signals.m_internals->BlockChecked.connect(std::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2)); | ||
connections.NewPoWValidBlock = g_signals.m_internals->NewPoWValidBlock.connect(std::bind(&CValidationInterface::NewPoWValidBlock, pwalletIn, _1, _2)); | ||
g_signals.m_wallet_connections.emplace(pwalletIn, connections); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could std::move
connections
src/validationinterface.cpp
Outdated
connections.ChainStateFlushed.disconnect(); | ||
connections.Broadcast.disconnect(); | ||
connections.BlockChecked.disconnect(); | ||
connections.NewPoWValidBlock.disconnect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could extract these as a method on ValidationInterfaceConnections
where it would be more clear whether the method was comprehensive in its disconnecting.
src/validationinterface.cpp
Outdated
connections.ChainStateFlushed = g_signals.m_internals->ChainStateFlushed.connect(std::bind(&CValidationInterface::ChainStateFlushed, pwalletIn, _1)); | ||
connections.Broadcast = g_signals.m_internals->Broadcast.connect(std::bind(&CValidationInterface::ResendWalletTransactions, pwalletIn, _1, _2)); | ||
connections.BlockChecked = g_signals.m_internals->BlockChecked.connect(std::bind(&CValidationInterface::BlockChecked, pwalletIn, _1, _2)); | ||
connections.NewPoWValidBlock = g_signals.m_internals->NewPoWValidBlock.connect(std::bind(&CValidationInterface::NewPoWValidBlock, pwalletIn, _1, _2)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could extract as a method on ValidationInterfaceConnections
Concept ACK. |
src/validationinterface.h
Outdated
@@ -6,10 +6,13 @@ | |||
#ifndef BITCOIN_VALIDATIONINTERFACE_H | |||
#define BITCOIN_VALIDATIONINTERFACE_H | |||
|
|||
#include <boost/signals2/signal.hpp> | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this will slow down the build significantly. So tend to NACK here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK cb53b82. Only change is last review is new comment.
utACK cb53b82 |
Can this be merged, or does it need more review? I see review from @theuni was requested in github, but I don't know if it's necessary given the other reviews since this change is pretty straightforward. |
utACK cb53b82 |
utACK cb53b82 |
cb53b82 scripted-diff: Replace boost::bind with std::bind (Chun Kuan Lee) 2196c51 refactor: Use boost::scoped_connection in signal/slot, also prefer range-based loop instead of std::transform (Chun Kuan Lee) Pull request description: Replace boost::bind with std::bind - In `src/rpc/server.cpp`, replace `std::transform` with simple loop. - In `src/validation.cpp`, store the `boost::signals2::connection` object and use it to disconnect. - In `src/validationinterface.cpp`, use 2 map to store the `boost::signals2::scoped_connection` object. Tree-SHA512: 6653cbe00036fecfc495340618efcba6d7be0227c752b37b81a27184433330f817e8de9257774e9b35828026cb55f11ee7f17d6c388aebe22c4a3df13b5092f0
boost::bind usage was removed in bitcoin#13743. However a new usage snuck in as part of 2bc4c3e (bitcoin#15225).
e36f802 lint: add C++ code linter (fanquake) c4be50f remove usage of boost::bind (fanquake) Pull request description: `boost::bind` usage was removed in #13743. However a new usage snuck in as part of 2bc4c3e (#15225). ACKs for top commit: hebasto: ACK e36f802 practicalswift: ACK e36f802 -- patch looks correct Tree-SHA512: 2b0387c5443c184bcbf7df4849db1ed1296ff82c7b4ff0aff18334a400e56a472a972d18234d3866531a088d7a8da64688e58dc9f15daaad4048697c759d55ce
-BEGIN VERIFY SCRIPT- for j in $(seq 1 5) do gsed -i "s/ _${j}/ std::placeholders::_${j}/g" $(git grep --name-only " _${j}" -- '*.cpp' '*.h') done gsed -i "s/boost::bind/std::bind/g" $(git grep --name-only boost::bind -- '*.cpp' '*.h') gsed -i "s/boost::ref/std::ref/g" $(git grep --name-only boost::ref -- '*.cpp' '*.h') gsed -i '/boost\/bind/d' $(git grep --name-only boost/bind) -END VERIFY SCRIPT-
-BEGIN VERIFY SCRIPT- for j in $(seq 1 5) do gsed -i "s/ _${j}/ std::placeholders::_${j}/g" $(git grep --name-only " _${j}" -- '*.cpp' '*.h') done gsed -i "s/boost::bind/std::bind/g" $(git grep --name-only boost::bind -- '*.cpp' '*.h') gsed -i "s/boost::ref/std::ref/g" $(git grep --name-only boost::ref -- '*.cpp' '*.h') gsed -i '/boost\/bind/d' $(git grep --name-only boost/bind) -END VERIFY SCRIPT-
… in signal/slot, also prefer range-based loop instead of std::transform # Conflicts: # src/validationinterface.cpp
…l/slot, also prefer range-based loop instead of std::transform
…l/slot, also prefer range-based loop instead of std::transform
…l/slot, also prefer range-based loop instead of std::transform
…l/slot, also prefer range-based loop instead of std::transform
merge bitcoin#15118, bitcoin#14172, bitcoin#15623, bitcoin#14121, partial bitcoin#13743, partial bitcoin#15280: block filters
cb53b82 scripted-diff: Replace boost::bind with std::bind (Chun Kuan Lee) 2196c51 refactor: Use boost::scoped_connection in signal/slot, also prefer range-based loop instead of std::transform (Chun Kuan Lee) Pull request description: Replace boost::bind with std::bind - In `src/rpc/server.cpp`, replace `std::transform` with simple loop. - In `src/validation.cpp`, store the `boost::signals2::connection` object and use it to disconnect. - In `src/validationinterface.cpp`, use 2 map to store the `boost::signals2::scoped_connection` object. Tree-SHA512: 6653cbe00036fecfc495340618efcba6d7be0227c752b37b81a27184433330f817e8de9257774e9b35828026cb55f11ee7f17d6c388aebe22c4a3df13b5092f0
cb53b82 scripted-diff: Replace boost::bind with std::bind (Chun Kuan Lee) 2196c51 refactor: Use boost::scoped_connection in signal/slot, also prefer range-based loop instead of std::transform (Chun Kuan Lee) Pull request description: Replace boost::bind with std::bind - In `src/rpc/server.cpp`, replace `std::transform` with simple loop. - In `src/validation.cpp`, store the `boost::signals2::connection` object and use it to disconnect. - In `src/validationinterface.cpp`, use 2 map to store the `boost::signals2::scoped_connection` object. Tree-SHA512: 6653cbe00036fecfc495340618efcba6d7be0227c752b37b81a27184433330f817e8de9257774e9b35828026cb55f11ee7f17d6c388aebe22c4a3df13b5092f0
cb53b82 scripted-diff: Replace boost::bind with std::bind (Chun Kuan Lee) 2196c51 refactor: Use boost::scoped_connection in signal/slot, also prefer range-based loop instead of std::transform (Chun Kuan Lee) Pull request description: Replace boost::bind with std::bind - In `src/rpc/server.cpp`, replace `std::transform` with simple loop. - In `src/validation.cpp`, store the `boost::signals2::connection` object and use it to disconnect. - In `src/validationinterface.cpp`, use 2 map to store the `boost::signals2::scoped_connection` object. Tree-SHA512: 6653cbe00036fecfc495340618efcba6d7be0227c752b37b81a27184433330f817e8de9257774e9b35828026cb55f11ee7f17d6c388aebe22c4a3df13b5092f0
cb53b82 scripted-diff: Replace boost::bind with std::bind (Chun Kuan Lee) 2196c51 refactor: Use boost::scoped_connection in signal/slot, also prefer range-based loop instead of std::transform (Chun Kuan Lee) Pull request description: Replace boost::bind with std::bind - In `src/rpc/server.cpp`, replace `std::transform` with simple loop. - In `src/validation.cpp`, store the `boost::signals2::connection` object and use it to disconnect. - In `src/validationinterface.cpp`, use 2 map to store the `boost::signals2::scoped_connection` object. Tree-SHA512: 6653cbe00036fecfc495340618efcba6d7be0227c752b37b81a27184433330f817e8de9257774e9b35828026cb55f11ee7f17d6c388aebe22c4a3df13b5092f0
…nd (#4343) * Merge bitcoin#13743: refactor: Replace boost::bind with std::bind cb53b82 scripted-diff: Replace boost::bind with std::bind (Chun Kuan Lee) 2196c51 refactor: Use boost::scoped_connection in signal/slot, also prefer range-based loop instead of std::transform (Chun Kuan Lee) Pull request description: Replace boost::bind with std::bind - In `src/rpc/server.cpp`, replace `std::transform` with simple loop. - In `src/validation.cpp`, store the `boost::signals2::connection` object and use it to disconnect. - In `src/validationinterface.cpp`, use 2 map to store the `boost::signals2::scoped_connection` object. Tree-SHA512: 6653cbe00036fecfc495340618efcba6d7be0227c752b37b81a27184433330f817e8de9257774e9b35828026cb55f11ee7f17d6c388aebe22c4a3df13b5092f0 * Replace boost::bind with std::bind and remove Boost.Bind includes Co-authored-by: MarcoFalke <falke.marco@gmail.com>
Replace boost::bind with std::bind
src/rpc/server.cpp
, replacestd::transform
with simple loop.src/validation.cpp
, store theboost::signals2::connection
object and use it to disconnect.src/validationinterface.cpp
, use 2 map to store theboost::signals2::scoped_connection
object.