未验证 提交 a172e6cc 编写于 作者: G gouzil 提交者: GitHub

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

* [clang-tidy] modernize-avoid-bind

* rollback
上级 84445499
......@@ -165,7 +165,7 @@ bugprone-unused-raii,
-hicpp-exception-baseclass,
-misc-unused-alias-decls,
-misc-unused-using-decls,
-modernize-avoid-bind,
modernize-avoid-bind,
-modernize-avoid-c-arrays,
-modernize-deprecated-headers,
-modernize-deprecated-ios-base-aliases,
......
......@@ -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); }));
}
}
......
......@@ -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); }));
}
}
......
......@@ -350,7 +350,8 @@ class CompileTimeInferShapeContext : public InferShapeContext {
names.begin(),
names.end(),
retv.begin(),
std::bind(std::mem_fn(&CompileTimeInferShapeContext::GetVarType),
std::bind(
std::mem_fn(&CompileTimeInferShapeContext::GetVarType), // NOLINT
this,
std::placeholders::_1));
return retv;
......
......@@ -710,10 +710,11 @@ 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(),
std::transform(
vars.begin(),
vars.end(),
retv.begin(),
std::bind(std::mem_fn(&RuntimeInferShapeContext::GetVarType),
std::bind(std::mem_fn(&RuntimeInferShapeContext::GetVarType), // NOLINT
this,
std::placeholders::_1));
return retv;
......
......@@ -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(); });
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册