Skip to content
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

[clang-tidy][task 46] enable modernize-avoid-bind #55895

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Checks: '
-hicpp-exception-baseclass,
-misc-unused-alias-decls,
-misc-unused-using-decls,
-modernize-avoid-bind,
modernize-avoid-bind,
GreatV marked this conversation as resolved.
Show resolved Hide resolved
-modernize-avoid-c-arrays,
-modernize-deprecated-headers,
-modernize-deprecated-ios-base-aliases,
Expand Down
3 changes: 1 addition & 2 deletions paddle/fluid/framework/dist_multi_trainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ void DistMultiTrainer::InitDumpEnv() {
}
}
for (int i = 0; i < dump_thread_num_; i++) {
dump_thread_.push_back(
std::thread(std::bind(&TrainerBase::DumpWork, this, i)));
dump_thread_.push_back(std::thread([this, i] { DumpWork(i); }));
}
}

Expand Down
3 changes: 1 addition & 2 deletions paddle/fluid/framework/multi_trainer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ void MultiTrainer::InitDumpEnv() {
}
}
for (int i = 0; i < dump_thread_num_; i++) {
dump_thread_.push_back(
std::thread(std::bind(&TrainerBase::DumpWork, this, i)));
dump_thread_.push_back(std::thread([this, i] { DumpWork(i); }));
}
}

Expand Down
7 changes: 4 additions & 3 deletions paddle/fluid/framework/op_desc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,10 @@ class CompileTimeInferShapeContext : public InferShapeContext {
names.begin(),
names.end(),
retv.begin(),
std::bind(std::mem_fn(&CompileTimeInferShapeContext::GetVarType),
this,
std::placeholders::_1));
std::bind(
std::mem_fn(&CompileTimeInferShapeContext::GetVarType), // NOLINT
this,
std::placeholders::_1));
return retv;
}

Expand Down
13 changes: 7 additions & 6 deletions paddle/fluid/framework/operator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -710,12 +710,13 @@ std::vector<proto::VarType::Type> RuntimeInferShapeContext::GetVarTypes(
const std::vector<Variable*>& vars) const {
std::vector<proto::VarType::Type> retv;
retv.resize(vars.size());
std::transform(vars.begin(),
vars.end(),
retv.begin(),
std::bind(std::mem_fn(&RuntimeInferShapeContext::GetVarType),
this,
std::placeholders::_1));
std::transform(
vars.begin(),
vars.end(),
retv.begin(),
std::bind(std::mem_fn(&RuntimeInferShapeContext::GetVarType), // NOLINT
this,
std::placeholders::_1));
return retv;
}

Expand Down
3 changes: 1 addition & 2 deletions paddle/phi/core/threadpool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ ThreadPool::ThreadPool(int num_threads) : running_(true) {
threads_.resize(num_threads);
for (auto& thread : threads_) {
// TODO(Yancey1989): binding the thread on the specify CPU numberw
thread =
std::make_unique<std::thread>(std::bind(&ThreadPool::TaskLoop, this));
thread = std::make_unique<std::thread>([this] { ThreadPool::TaskLoop(); });
}
}

Expand Down