diff --git a/.clang-tidy b/.clang-tidy index c13a3811f008265e06ca9db7e15ca0db28613263..67b42a531cf275931226e06a672c169d65e07150 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -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, diff --git a/paddle/fluid/framework/dist_multi_trainer.cc b/paddle/fluid/framework/dist_multi_trainer.cc index 5b93b4bcef423385f131701215a96be55fdc709e..3a5787a665cfc4517c40dd79f19bd6a8f17c971c 100644 --- a/paddle/fluid/framework/dist_multi_trainer.cc +++ b/paddle/fluid/framework/dist_multi_trainer.cc @@ -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); })); } } diff --git a/paddle/fluid/framework/multi_trainer.cc b/paddle/fluid/framework/multi_trainer.cc index 220b11efb1b8add450ed97a184cf9b46d7b53c4e..923b8c406c0a5f19fcfd3e671d02f207a5830488 100644 --- a/paddle/fluid/framework/multi_trainer.cc +++ b/paddle/fluid/framework/multi_trainer.cc @@ -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); })); } } diff --git a/paddle/fluid/framework/op_desc.cc b/paddle/fluid/framework/op_desc.cc index 69939df7619e03104c681ad337f4051cfd815a83..bd0c40b3287c0c771e4816b4086a8d4116f15ddc 100644 --- a/paddle/fluid/framework/op_desc.cc +++ b/paddle/fluid/framework/op_desc.cc @@ -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; } diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index 1b55dea874aa07450c0a149554d66d4ffea0d56e..e9192732124be8f84ec2f19b207972a88242fdf2 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -710,12 +710,13 @@ std::vector RuntimeInferShapeContext::GetVarTypes( const std::vector& vars) const { std::vector 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; } diff --git a/paddle/phi/core/threadpool.cc b/paddle/phi/core/threadpool.cc index 482f8c9bf83b38f474e3acd65ebdbe8d6dacae9c..d820df80e7ddaa0b238df70bc8e471c9cc4a4886 100644 --- a/paddle/phi/core/threadpool.cc +++ b/paddle/phi/core/threadpool.cc @@ -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::bind(&ThreadPool::TaskLoop, this)); + thread = std::make_unique([this] { ThreadPool::TaskLoop(); }); } }