From: Daniel Arndt Date: Sun, 22 Sep 2019 01:05:12 +0000 (-0400) Subject: Remove std::bind from include (apart from documentation) X-Git-Tag: v9.2.0-rc1~1037^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1440e7b10c7a6ba0c3ec63a35eba01d2000c767a;p=dealii.git Remove std::bind from include (apart from documentation) --- diff --git a/include/deal.II/base/parallel.h b/include/deal.II/base/parallel.h index 6d06ddf929..f68b6a9db4 100644 --- a/include/deal.II/base/parallel.h +++ b/include/deal.II/base/parallel.h @@ -463,13 +463,13 @@ namespace parallel ff(begin, end); # endif #else - internal::parallel_for( - begin, - end, - std::bind(&internal::apply_to_subranges, - std::placeholders::_1, - std::cref(f)), - grainsize); + internal::parallel_for(begin, + end, + [&f](const tbb::blocked_range &range) { + internal::apply_to_subranges( + range, f); + }, + grainsize); #endif } diff --git a/include/deal.II/base/quadrature_point_data.h b/include/deal.II/base/quadrature_point_data.h index ab9467e579..106dbd468d 100644 --- a/include/deal.II/base/quadrature_point_data.h +++ b/include/deal.II/base/quadrature_point_data.h @@ -939,11 +939,11 @@ namespace parallel data_storage = &data_storage_; handle = triangulation->register_data_attach( - std::bind( - &ContinuousQuadratureDataTransfer::pack_function, - this, - std::placeholders::_1, - std::placeholders::_2), + [this]( + const typename parallel::distributed::Triangulation< + dim>::cell_iterator &cell, + const typename parallel::distributed::Triangulation::CellStatus + status) { return this->pack_function(cell, status); }, /*returns_variable_size_data=*/true); } @@ -955,12 +955,13 @@ namespace parallel { triangulation->notify_ready_to_unpack( handle, - std::bind( - &ContinuousQuadratureDataTransfer::unpack_function, - this, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3)); + [this]( + const typename parallel::distributed::Triangulation< + dim>::cell_iterator &cell, + const typename parallel::distributed::Triangulation::CellStatus + status, + const boost::iterator_range::const_iterator> + &data_range) { this->unpack_function(cell, status, data_range); }); // invalidate the pointers data_storage = nullptr; diff --git a/include/deal.II/base/time_stepping.templates.h b/include/deal.II/base/time_stepping.templates.h index b1f31024c3..285b9cc0d7 100644 --- a/include/deal.II/base/time_stepping.templates.h +++ b/include/deal.II/base/time_stepping.templates.h @@ -375,18 +375,16 @@ namespace TimeStepping // Solve the nonlinear system using Newton's method const double new_t = t + this->c[i] * delta_t; const double new_delta_t = this->a[i][i] * delta_t; + VectorType & f_stage = f_stages[i]; newton_solve( - std::bind(&ImplicitRungeKutta::compute_residual, - this, - f, - new_t, - new_delta_t, - std::cref(old_y), - std::placeholders::_1, - std::ref(f_stages[i]), - std::placeholders::_2), - std::bind( - id_minus_tau_J_inverse, new_t, new_delta_t, std::placeholders::_1), + [this, &f, new_t, new_delta_t, &old_y, &f_stage]( + const VectorType &y, VectorType &residual) { + this->compute_residual( + f, new_t, new_delta_t, old_y, y, f_stage, residual); + }, + [&id_minus_tau_J_inverse, new_t, new_delta_t](const VectorType &y) { + return id_minus_tau_J_inverse(new_t, new_delta_t, y); + }, y); } } diff --git a/include/deal.II/base/work_stream.h b/include/deal.II/base/work_stream.h index 86a025ba0d..1c7470f6c8 100644 --- a/include/deal.II/base/work_stream.h +++ b/include/deal.II/base/work_stream.h @@ -1225,9 +1225,11 @@ namespace WorkStream parallel::internal::parallel_for( colored_iterators[color].begin(), colored_iterators[color].end(), - std::bind(&WorkerAndCopier::operator(), - std::ref(worker_and_copier), - std::placeholders::_1), + [&worker_and_copier]( + const tbb::blocked_range< + typename std::vector::const_iterator> &range) { + worker_and_copier(range); + }, chunk_size); } } @@ -1283,12 +1285,14 @@ namespace WorkStream // forward to the other function run(begin, end, - std::bind(worker, - std::ref(main_object), - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3), - std::bind(copier, std::ref(main_object), std::placeholders::_1), + [&main_object, worker](const Iterator &iterator, + ScratchData & scratch_data, + CopyData & copy_data) { + (main_object.*worker)(iterator, scratch_data, copy_data); + }, + [&main_object, copier](const CopyData ©_data) { + (main_object.*copier)(copy_data); + }, sample_scratch_data, sample_copy_data, queue_length, @@ -1314,12 +1318,14 @@ namespace WorkStream // forward to the other function run(begin, end, - std::bind(worker, - std::ref(main_object), - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3), - std::bind(copier, std::ref(main_object), std::placeholders::_1), + [&main_object, worker](const Iterator &iterator, + ScratchData & scratch_data, + CopyData & copy_data) { + (main_object.*worker)(iterator, scratch_data, copy_data); + }, + [&main_object, copier](const CopyData ©_data) { + (main_object.*copier)(copy_data); + }, sample_scratch_data, sample_copy_data, queue_length, diff --git a/include/deal.II/distributed/cell_data_transfer.templates.h b/include/deal.II/distributed/cell_data_transfer.templates.h index ed4e233e0c..a05a1d64d4 100644 --- a/include/deal.II/distributed/cell_data_transfer.templates.h +++ b/include/deal.II/distributed/cell_data_transfer.templates.h @@ -143,10 +143,12 @@ namespace parallel Assert(tria != nullptr, ExcInternalError()); handle = tria->register_data_attach( - std::bind(&CellDataTransfer::pack_callback, - this, - std::placeholders::_1, - std::placeholders::_2), + [this](const typename parallel::distributed:: + Triangulation::cell_iterator &cell, + const typename parallel::distributed:: + Triangulation::CellStatus status) { + return this->pack_callback(cell, status); + }, /*returns_variable_size_data=*/transfer_variable_size_data); } @@ -215,12 +217,15 @@ namespace parallel tria->notify_ready_to_unpack( handle, - std::bind(&CellDataTransfer::unpack_callback, - this, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3, - std::ref(all_out))); + [this, &all_out]( + const typename parallel::distributed::Triangulation:: + cell_iterator &cell, + const typename parallel::distributed::Triangulation:: + CellStatus status, + const boost::iterator_range::const_iterator> + &data_range) { + this->unpack_callback(cell, status, data_range, all_out); + }); dealii::internal::parallel::distributed::CellDataTransferImplementation:: post_unpack_action(all_out); diff --git a/include/deal.II/lac/chunk_sparse_matrix.templates.h b/include/deal.II/lac/chunk_sparse_matrix.templates.h index 4fb16052ef..0c5929a59b 100644 --- a/include/deal.II/lac/chunk_sparse_matrix.templates.h +++ b/include/deal.II/lac/chunk_sparse_matrix.templates.h @@ -396,11 +396,11 @@ ChunkSparseMatrix::operator=(const double d) parallel::apply_to_subranges( 0U, matrix_size, - std::bind(&internal::ChunkSparseMatrixImplementation:: - template zero_subrange, - std::placeholders::_1, - std::placeholders::_2, - val.get()), + [this](const unsigned int begin, const unsigned int end) { + internal::ChunkSparseMatrixImplementation::zero_subrange(begin, + end, + val.get()); + }, grain_size); else if (matrix_size > 0) std::memset(val.get(), 0, matrix_size * sizeof(number)); @@ -507,9 +507,7 @@ ChunkSparseMatrix::n_actually_nonzero_elements() const return std::count_if(val.get(), val.get() + cols->sparsity_pattern.n_nonzero_elements() * chunk_size * chunk_size, - std::bind(std::not_equal_to(), - std::placeholders::_1, - 0)); + [](const double element) { return element != 0.; }); } @@ -707,16 +705,18 @@ ChunkSparseMatrix::vmult_add(OutVector &dst, const InVector &src) const parallel::apply_to_subranges( 0U, cols->sparsity_pattern.n_rows(), - std::bind(&internal::ChunkSparseMatrixImplementation:: - vmult_add_on_subrange, - std::cref(*cols), - std::placeholders::_1, - std::placeholders::_2, - val.get(), - cols->sparsity_pattern.rowstart.get(), - cols->sparsity_pattern.colnums.get(), - std::cref(src), - std::ref(dst)), + [this, &src, &dst](const unsigned int begin_row, + const unsigned int end_row) { + internal::ChunkSparseMatrixImplementation::vmult_add_on_subrange( + *cols, + begin_row, + end_row, + val.get(), + cols->sparsity_pattern.rowstart.get(), + cols->sparsity_pattern.colnums.get(), + src, + dst); + }, internal::SparseMatrixImplementation::minimum_parallel_grain_size / cols->chunk_size + 1); diff --git a/include/deal.II/lac/precondition.h b/include/deal.II/lac/precondition.h index 01cbd8001b..45119c8473 100644 --- a/include/deal.II/lac/precondition.h +++ b/include/deal.II/lac/precondition.h @@ -2267,10 +2267,10 @@ PreconditionChebyshev:: internal::PreconditionChebyshevImplementation::EigenvalueTracker eigenvalue_tracker; SolverCG solver(control); - solver.connect_eigenvalues_slot(std::bind( - &internal::PreconditionChebyshevImplementation::EigenvalueTracker::slot, - &eigenvalue_tracker, - std::placeholders::_1)); + solver.connect_eigenvalues_slot( + [&eigenvalue_tracker](const std::vector &eigenvalues) { + eigenvalue_tracker.slot(eigenvalues); + }); // set an initial guess which is close to the constant vector but where // one entry is different to trigger high frequencies diff --git a/include/deal.II/lac/relaxation_block.templates.h b/include/deal.II/lac/relaxation_block.templates.h index ea8e13934b..988bf5d73a 100644 --- a/include/deal.II/lac/relaxation_block.templates.h +++ b/include/deal.II/lac/relaxation_block.templates.h @@ -100,15 +100,13 @@ RelaxationBlock::invert_diagblocks() else { // compute blocks in parallel - parallel::apply_to_subranges( - 0, - this->additional_data->block_list.n_rows(), - std::bind(&RelaxationBlock:: - block_kernel, - this, - std::placeholders::_1, - std::placeholders::_2), - 16); + parallel::apply_to_subranges(0, + this->additional_data->block_list.n_rows(), + [this](const size_type block_begin, + const size_type block_end) { + this->block_kernel(block_begin, block_end); + }, + 16); } this->inverses_computed(true); } diff --git a/include/deal.II/lac/solver.h b/include/deal.II/lac/solver.h index 242c78cded..438959d236 100644 --- a/include/deal.II/lac/solver.h +++ b/include/deal.II/lac/solver.h @@ -523,10 +523,11 @@ inline SolverBase::SolverBase( // only takes two arguments, the iteration and the check_value, and so // we simply ignore the third argument that is passed in whenever the // signal is executed - connect(std::bind(&SolverControl::check, - std::ref(solver_control), - std::placeholders::_1, - std::placeholders::_2)); + connect([&solver_control](const unsigned int iteration, + const double check_value, + const VectorType &) { + return solver_control.check(iteration, check_value); + }); } @@ -540,10 +541,11 @@ inline SolverBase::SolverBase(SolverControl &solver_control) // only takes two arguments, the iteration and the check_value, and so // we simply ignore the third argument that is passed in whenever the // signal is executed - connect(std::bind(&SolverControl::check, - std::ref(solver_control), - std::placeholders::_1, - std::placeholders::_2)); + connect([&solver_control](const unsigned int iteration, + const double check_value, + const VectorType &) { + return solver_control.check(iteration, check_value); + }); } diff --git a/include/deal.II/lac/sparse_matrix.templates.h b/include/deal.II/lac/sparse_matrix.templates.h index 46f7e7898e..429a51660a 100644 --- a/include/deal.II/lac/sparse_matrix.templates.h +++ b/include/deal.II/lac/sparse_matrix.templates.h @@ -212,11 +212,11 @@ SparseMatrix::operator=(const double d) parallel::apply_to_subranges( 0U, matrix_size, - std::bind( - &internal::SparseMatrixImplementation::template zero_subrange, - std::placeholders::_1, - std::placeholders::_2, - val.get()), + [this](const size_type begin, const size_type end) { + internal::SparseMatrixImplementation::zero_subrange(begin, + end, + val.get()); + }, grain_size); else if (matrix_size > 0) { @@ -778,16 +778,17 @@ SparseMatrix::vmult(OutVector &dst, const InVector &src) const parallel::apply_to_subranges( 0U, m(), - std::bind(&internal::SparseMatrixImplementation:: - vmult_on_subrange, - std::placeholders::_1, - std::placeholders::_2, - val.get(), - cols->rowstart.get(), - cols->colnums.get(), - std::cref(src), - std::ref(dst), - false), + [this, &src, &dst](const size_type begin_row, const size_type end_row) { + internal::SparseMatrixImplementation::vmult_on_subrange( + begin_row, + end_row, + val.get(), + cols->rowstart.get(), + cols->colnums.get(), + src, + dst, + false); + }, internal::SparseMatrixImplementation::minimum_parallel_grain_size); } @@ -835,16 +836,17 @@ SparseMatrix::vmult_add(OutVector &dst, const InVector &src) const parallel::apply_to_subranges( 0U, m(), - std::bind(&internal::SparseMatrixImplementation:: - vmult_on_subrange, - std::placeholders::_1, - std::placeholders::_2, - val.get(), - cols->rowstart.get(), - cols->colnums.get(), - std::cref(src), - std::ref(dst), - true), + [this, &src, &dst](const size_type begin_row, const size_type end_row) { + internal::SparseMatrixImplementation::vmult_on_subrange( + begin_row, + end_row, + val.get(), + cols->rowstart.get(), + cols->colnums.get(), + src, + dst, + true); + }, internal::SparseMatrixImplementation::minimum_parallel_grain_size); } @@ -922,14 +924,15 @@ SparseMatrix::matrix_norm_square(const Vector &v) const Assert(n() == v.size(), ExcDimensionMismatch(n(), v.size())); return parallel::accumulate_from_subranges( - std::bind(&internal::SparseMatrixImplementation:: - matrix_norm_sqr_on_subrange>, - std::placeholders::_1, - std::placeholders::_2, - val.get(), - cols->rowstart.get(), - cols->colnums.get(), - std::cref(v)), + [this, &v](const size_type begin_row, const size_type end_row) { + return internal::SparseMatrixImplementation::matrix_norm_sqr_on_subrange( + begin_row, + end_row, + val.get(), + cols->rowstart.get(), + cols->colnums.get(), + v); + }, 0, m(), internal::SparseMatrixImplementation::minimum_parallel_grain_size); @@ -989,15 +992,16 @@ SparseMatrix::matrix_scalar_product(const Vector &u, Assert(n() == v.size(), ExcDimensionMismatch(n(), v.size())); return parallel::accumulate_from_subranges( - std::bind(&internal::SparseMatrixImplementation:: - matrix_scalar_product_on_subrange>, - std::placeholders::_1, - std::placeholders::_2, - val.get(), - cols->rowstart.get(), - cols->colnums.get(), - std::cref(u), - std::cref(v)), + [this, &u, &v](const size_type begin_row, const size_type end_row) { + return internal::SparseMatrixImplementation:: + matrix_scalar_product_on_subrange(begin_row, + end_row, + val.get(), + cols->rowstart.get(), + cols->colnums.get(), + u, + v); + }, 0, m(), internal::SparseMatrixImplementation::minimum_parallel_grain_size); @@ -1337,18 +1341,17 @@ SparseMatrix::residual(Vector & dst, Assert(&u != &dst, ExcSourceEqualsDestination()); return std::sqrt(parallel::accumulate_from_subranges( - std::bind(&internal::SparseMatrixImplementation::residual_sqr_on_subrange< - number, - Vector, - Vector>, - std::placeholders::_1, - std::placeholders::_2, - val.get(), - cols->rowstart.get(), - cols->colnums.get(), - std::cref(u), - std::cref(b), - std::ref(dst)), + [this, &u, &b, &dst](const size_type begin_row, const size_type end_row) { + return internal::SparseMatrixImplementation::residual_sqr_on_subrange( + begin_row, + end_row, + val.get(), + cols->rowstart.get(), + cols->colnums.get(), + u, + b, + dst); + }, 0, m(), internal::SparseMatrixImplementation::minimum_parallel_grain_size)); diff --git a/include/deal.II/matrix_free/dof_info.templates.h b/include/deal.II/matrix_free/dof_info.templates.h index de4bbf4e3c..dff2d5b367 100644 --- a/include/deal.II/matrix_free/dof_info.templates.h +++ b/include/deal.II/matrix_free/dof_info.templates.h @@ -1571,12 +1571,13 @@ namespace internal n_rows / internal::bucket_size_threading + 1); parallel::apply_to_subranges(0, task_info.n_active_cells, - std::bind(&internal::compute_row_lengths, - std::placeholders::_1, - std::placeholders::_2, - std::cref(*this), - std::ref(mutexes), - std::ref(row_lengths)), + [this, + &mutexes, + &row_lengths](const unsigned int begin, + const unsigned int end) { + internal::compute_row_lengths( + begin, end, *this, mutexes, row_lengths); + }, 20); // disregard dofs that only sit on a single cell because they cannot @@ -1591,16 +1592,15 @@ namespace internal SparsityPattern connectivity_dof(n_rows, task_info.n_active_cells, row_lengths); - parallel::apply_to_subranges(0, - task_info.n_active_cells, - std::bind(&internal::fill_connectivity_dofs, - std::placeholders::_1, - std::placeholders::_2, - std::cref(*this), - std::cref(row_lengths), - std::ref(mutexes), - std::ref(connectivity_dof)), - 20); + parallel::apply_to_subranges( + 0, + task_info.n_active_cells, + [this, &row_lengths, &mutexes, &connectivity_dof]( + const unsigned int begin, const unsigned int end) { + internal::fill_connectivity_dofs( + begin, end, *this, row_lengths, mutexes, connectivity_dof); + }, + 20); connectivity_dof.compress(); @@ -1612,16 +1612,19 @@ namespace internal // create a connectivity list between cells. The connectivity graph // should apply the renumbering, i.e., the entry for cell j is the entry // for cell renumbering[j] in the original ordering. - parallel::apply_to_subranges(0, - task_info.n_active_cells, - std::bind(&internal::fill_connectivity, - std::placeholders::_1, - std::placeholders::_2, - std::cref(*this), - std::cref(reverse_numbering), - std::cref(connectivity_dof), - std::ref(connectivity)), - 20); + parallel::apply_to_subranges( + 0, + task_info.n_active_cells, + [this, &reverse_numbering, &connectivity_dof, &connectivity]( + const unsigned int begin, const unsigned int end) { + internal::fill_connectivity(begin, + end, + *this, + reverse_numbering, + connectivity_dof, + connectivity); + }, + 20); } diff --git a/include/deal.II/matrix_free/matrix_free.templates.h b/include/deal.II/matrix_free/matrix_free.templates.h index c7fb9ce1da..23a95f1083 100644 --- a/include/deal.II/matrix_free/matrix_free.templates.h +++ b/include/deal.II/matrix_free/matrix_free.templates.h @@ -1872,14 +1872,13 @@ MatrixFree::make_connectivity_graph_faces( tbb::concurrent_unordered_map, unsigned int> map; - parallel::apply_to_subranges(0, - cell_level_index.size(), - std::bind(&internal::fill_index_subrange, - std::placeholders::_1, - std::placeholders::_2, - std::cref(cell_level_index), - std::ref(map)), - 50); + parallel::apply_to_subranges( + 0, + cell_level_index.size(), + [this, &map](const unsigned int begin, const unsigned int end) { + internal::fill_index_subrange(begin, end, cell_level_index, map); + }, + 50); // step 2: Make a list for all blocks with other blocks that write to the // cell (due to the faces that are associated to it) @@ -1892,13 +1891,11 @@ MatrixFree::make_connectivity_graph_faces( parallel::apply_to_subranges( 0, task_info.n_active_cells, - std::bind(&internal::fill_connectivity_subrange, - std::placeholders::_1, - std::placeholders::_2, - std::cref(tria), - std::cref(cell_level_index), - std::cref(map), - std::ref(connectivity_direct)), + [this, &tria, &map, &connectivity_direct](const unsigned int begin, + const unsigned int end) { + internal::fill_connectivity_subrange( + begin, end, tria, cell_level_index, map, connectivity_direct); + }, 20); connectivity_direct.symmetrize(); @@ -1907,11 +1904,13 @@ MatrixFree::make_connectivity_graph_faces( parallel::apply_to_subranges( 0, task_info.n_active_cells, - std::bind(&internal::fill_connectivity_indirect_subrange, - std::placeholders::_1, - std::placeholders::_2, - std::cref(connectivity_direct), - std::ref(connectivity)), + [&connectivity_direct, &connectivity](const unsigned int begin, + const unsigned int end) { + internal::fill_connectivity_indirect_subrange(begin, + end, + connectivity_direct, + connectivity); + }, 20); #endif } diff --git a/include/deal.II/meshworker/loop.h b/include/deal.II/meshworker/loop.h index 426abcf69a..bf07441355 100644 --- a/include/deal.II/meshworker/loop.h +++ b/include/deal.II/meshworker/loop.h @@ -471,17 +471,19 @@ namespace MeshWorker WorkStream::run( begin, end, - std::bind(&cell_action, - std::placeholders::_1, - std::placeholders::_3, - std::placeholders::_2, - cell_worker, - boundary_worker, - face_worker, - lctrl), - std::bind(&dealii::internal::assemble, - std::placeholders::_1, - &assembler), + [&cell_worker, &boundary_worker, &face_worker, &lctrl]( + ITERATOR cell, INFOBOX &info, DoFInfoBox &dof_info) { + cell_action(cell, + dof_info, + info, + cell_worker, + boundary_worker, + face_worker, + lctrl); + }, + [&assembler](const MeshWorker::DoFInfoBox &dinfo) { + dealii::internal::assemble(dinfo, &assembler); + }, info, dof_info); } @@ -516,22 +518,28 @@ namespace MeshWorker IntegrationInfo &)> face_worker; if (integrator.use_cell) - cell_worker = std::bind(&LocalIntegrator::cell, - &integrator, - std::placeholders::_1, - std::placeholders::_2); + cell_worker = + [&integrator](DoFInfo & dof_info, + IntegrationInfo &integration_info) { + integrator.cell(dof_info, integration_info); + }; if (integrator.use_boundary) - boundary_worker = std::bind(&LocalIntegrator::boundary, - &integrator, - std::placeholders::_1, - std::placeholders::_2); + boundary_worker = + [&integrator](DoFInfo & dof_info, + IntegrationInfo &integration_info) { + integrator.boundary(dof_info, integration_info); + }; if (integrator.use_face) - face_worker = std::bind(&LocalIntegrator::face, - &integrator, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3, - std::placeholders::_4); + face_worker = + [&integrator](DoFInfo & dof_info_1, + DoFInfo & dof_info_2, + IntegrationInfo &integration_info_1, + IntegrationInfo &integration_info_2) { + integrator.face(dof_info_1, + dof_info_2, + integration_info_1, + integration_info_2); + }; loop(begin, end, diff --git a/include/deal.II/meshworker/mesh_loop.h b/include/deal.II/meshworker/mesh_loop.h index 6e03cf2a30..8c8d79f7cc 100644 --- a/include/deal.II/meshworker/mesh_loop.h +++ b/include/deal.II/meshworker/mesh_loop.h @@ -698,36 +698,49 @@ namespace MeshWorker f_face_worker; if (cell_worker != nullptr) - f_cell_worker = std::bind(cell_worker, - std::ref(main_class), - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3); + f_cell_worker = [&main_class, + cell_worker](const CellIteratorType &cell_iterator, + ScratchData & scratch_data, + CopyData & copy_data) { + (main_class.*cell_worker)(cell_iterator, scratch_data, copy_data); + }; if (boundary_worker != nullptr) - f_boundary_worker = std::bind(boundary_worker, - std::ref(main_class), - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3, - std::placeholders::_4); + f_boundary_worker = + [&main_class, boundary_worker](const CellIteratorType &cell_iterator, + const unsigned int face_no, + ScratchData & scratch_data, + CopyData & copy_data) { + (main_class.* + boundary_worker)(cell_iterator, face_no, scratch_data, copy_data); + }; if (face_worker != nullptr) - f_face_worker = std::bind(face_worker, - std::ref(main_class), - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3, - std::placeholders::_4, - std::placeholders::_5, - std::placeholders::_6, - std::placeholders::_7, - std::placeholders::_8); + f_face_worker = [&main_class, + face_worker](const CellIteratorType &cell_iterator_1, + const unsigned int face_index_1, + const unsigned int subface_index_1, + const CellIteratorType &cell_iterator_2, + const unsigned int face_index_2, + const unsigned int subface_index_2, + ScratchData & scratch_data, + CopyData & copy_data) { + (main_class.*face_worker)(cell_iterator_1, + face_index_1, + subface_index_1, + cell_iterator_2, + face_index_2, + subface_index_2, + scratch_data, + copy_data); + }; mesh_loop(begin, end, f_cell_worker, - std::bind(copier, main_class, std::placeholders::_1), + [&main_class, copier](const CopyData ©_data) { + (main_class.*copier)(copy_data); + }, sample_scratch_data, sample_copy_data, flags, diff --git a/include/deal.II/numerics/error_estimator.templates.h b/include/deal.II/numerics/error_estimator.templates.h index 9ad9583c41..c7fd6940c9 100644 --- a/include/deal.II/numerics/error_estimator.templates.h +++ b/include/deal.II/numerics/error_estimator.templates.h @@ -1307,15 +1307,21 @@ KellyErrorEstimator::estimate( dof_handler.begin_active(), static_cast( dof_handler.end()), - std::bind(&internal::estimate_one_cell, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3, - std::ref(solutions), - strategy), - std::bind(&internal::copy_local_to_global, - std::placeholders::_1, - std::ref(face_integrals)), + [&solutions, strategy]( + const typename DoFHandlerType::active_cell_iterator &cell, + internal::ParallelData + ¶llel_data, + std::map> + &local_face_integrals) { + internal::estimate_one_cell( + cell, parallel_data, local_face_integrals, solutions, strategy); + }, + [&face_integrals]( + const std::map> &local_face_integrals) { + internal::copy_local_to_global(local_face_integrals, + face_integrals); + }, parallel_data, sample_local_face_integrals); diff --git a/include/deal.II/numerics/matrix_creator.templates.h b/include/deal.II/numerics/matrix_creator.templates.h index 1ae593cea3..12fe44a90f 100644 --- a/include/deal.II/numerics/matrix_creator.templates.h +++ b/include/deal.II/numerics/matrix_creator.templates.h @@ -741,12 +741,10 @@ namespace MatrixCreator spacedim, typename DoFHandler::active_cell_iterator, number>, - std::bind( - &MatrixCreator::internal:: - copy_local_to_global, Vector>, - std::placeholders::_1, - &matrix, - static_cast *>(nullptr)), + [&matrix](const internal::AssemblerData::CopyData &data) { + MatrixCreator::internal::copy_local_to_global( + data, &matrix, static_cast *>(nullptr)); + }, assembler_data, copy_data); } @@ -816,12 +814,12 @@ namespace MatrixCreator spacedim, typename DoFHandler::active_cell_iterator, number>, - std::bind( - &MatrixCreator::internal:: - copy_local_to_global, Vector>, - std::placeholders::_1, - &matrix, - &rhs_vector), + [&matrix, + &rhs_vector](const internal::AssemblerData::CopyData &data) { + MatrixCreator::internal::copy_local_to_global(data, + &matrix, + &rhs_vector); + }, assembler_data, copy_data); } @@ -891,12 +889,10 @@ namespace MatrixCreator spacedim, typename hp::DoFHandler::active_cell_iterator, number>, - std::bind( - &MatrixCreator::internal:: - copy_local_to_global, Vector>, - std::placeholders::_1, - &matrix, - static_cast *>(nullptr)), + [&matrix](const internal::AssemblerData::CopyData &data) { + MatrixCreator::internal::copy_local_to_global( + data, &matrix, static_cast *>(nullptr)); + }, assembler_data, copy_data); } @@ -963,12 +959,12 @@ namespace MatrixCreator spacedim, typename hp::DoFHandler::active_cell_iterator, number>, - std::bind( - &MatrixCreator::internal:: - copy_local_to_global, Vector>, - std::placeholders::_1, - &matrix, - &rhs_vector), + [&matrix, + &rhs_vector](const internal::AssemblerData::CopyData &data) { + MatrixCreator::internal::copy_local_to_global(data, + &matrix, + &rhs_vector); + }, assembler_data, copy_data); } @@ -1405,31 +1401,30 @@ namespace MatrixCreator WorkStream::run( dof.begin_active(), dof.end(), - static_cast::active_cell_iterator const &, - MatrixCreator::internal::AssemblerBoundary::Scratch const &, - MatrixCreator::internal::AssemblerBoundary:: - CopyData, number> &)>>( - std::bind( - &internal::create_boundary_mass_matrix_1, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3, - std::cref(mapping), - std::cref(fe), - std::cref(q), - std::cref(boundary_functions), - coefficient, - std::cref(component_mapping))), - static_cast, number> const &)>>( - std::bind(&internal::copy_boundary_mass_matrix_1, - std::placeholders::_1, - std::cref(boundary_functions), - std::cref(dof_to_boundary_mapping), - std::ref(matrix), - std::ref(rhs_vector))), + [&mapping, &fe, &q, &boundary_functions, coefficient, &component_mapping]( + typename DoFHandler::active_cell_iterator const &cell, + MatrixCreator::internal::AssemblerBoundary::Scratch const &scratch_data, + MatrixCreator::internal::AssemblerBoundary:: + CopyData, number> ©_data) { + internal::create_boundary_mass_matrix_1(cell, + scratch_data, + copy_data, + mapping, + fe, + q, + boundary_functions, + coefficient, + component_mapping); + }, + [&boundary_functions, &dof_to_boundary_mapping, &matrix, &rhs_vector]( + MatrixCreator::internal::AssemblerBoundary:: + CopyData, number> const ©_data) { + internal::copy_boundary_mass_matrix_1(copy_data, + boundary_functions, + dof_to_boundary_mapping, + matrix, + rhs_vector); + }, scratch, copy_data); } @@ -1879,32 +1874,36 @@ namespace MatrixCreator WorkStream::run( dof.begin_active(), dof.end(), - static_cast::active_cell_iterator const &, - MatrixCreator::internal::AssemblerBoundary::Scratch const &, - MatrixCreator::internal::AssemblerBoundary:: - CopyData, number> &)>>( - std::bind( - &internal::create_hp_boundary_mass_matrix_1, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3, - std::cref(mapping), - std::cref(fe_collection), - std::cref(q), - std::cref(boundary_functions), - coefficient, - std::cref(component_mapping))), - static_cast::active_cell_iterator const + & cell, + MatrixCreator::internal::AssemblerBoundary::Scratch const &scratch_data, + MatrixCreator::internal::AssemblerBoundary :: + CopyData, number> ©_data) { + internal::create_hp_boundary_mass_matrix_1(cell, + scratch_data, + copy_data, + mapping, + fe_collection, + q, + boundary_functions, + coefficient, + component_mapping); + }, + [&boundary_functions, &dof_to_boundary_mapping, &matrix, &rhs_vector]( MatrixCreator::internal::AssemblerBoundary :: - CopyData, number> const &)>>( - std::bind( - &internal::copy_hp_boundary_mass_matrix_1, - std::placeholders::_1, - std::cref(boundary_functions), - std::cref(dof_to_boundary_mapping), - std::ref(matrix), - std::ref(rhs_vector))), + CopyData, number> const ©_data) { + internal::copy_hp_boundary_mass_matrix_1(copy_data, + boundary_functions, + dof_to_boundary_mapping, + matrix, + rhs_vector); + }, scratch, copy_data); } @@ -1980,12 +1979,10 @@ namespace MatrixCreator dim, spacedim, typename DoFHandler::active_cell_iterator>, - std::bind( - &MatrixCreator::internal:: - copy_local_to_global, Vector>, - std::placeholders::_1, - &matrix, - static_cast *>(nullptr)), + [&matrix](const internal::AssemblerData::CopyData &data) { + MatrixCreator::internal::copy_local_to_global( + data, &matrix, static_cast *>(nullptr)); + }, assembler_data, copy_data); } @@ -2054,12 +2051,12 @@ namespace MatrixCreator dim, spacedim, typename DoFHandler::active_cell_iterator>, - std::bind( - &MatrixCreator::internal:: - copy_local_to_global, Vector>, - std::placeholders::_1, - &matrix, - &rhs_vector), + [&matrix, + &rhs_vector](const internal::AssemblerData::CopyData &data) { + MatrixCreator::internal::copy_local_to_global(data, + &matrix, + &rhs_vector); + }, assembler_data, copy_data); } @@ -2128,12 +2125,10 @@ namespace MatrixCreator dim, spacedim, typename hp::DoFHandler::active_cell_iterator>, - std::bind( - &MatrixCreator::internal:: - copy_local_to_global, Vector>, - std::placeholders::_1, - &matrix, - static_cast *>(nullptr)), + [&matrix](const internal::AssemblerData::CopyData &data) { + MatrixCreator::internal::copy_local_to_global( + data, &matrix, static_cast *>(nullptr)); + }, assembler_data, copy_data); } @@ -2200,12 +2195,12 @@ namespace MatrixCreator dim, spacedim, typename hp::DoFHandler::active_cell_iterator>, - std::bind( - &MatrixCreator::internal:: - copy_local_to_global, Vector>, - std::placeholders::_1, - &matrix, - &rhs_vector), + [&matrix, + &rhs_vector](const internal::AssemblerData::CopyData &data) { + MatrixCreator::internal::copy_local_to_global(data, + &matrix, + &rhs_vector); + }, assembler_data, copy_data); }