From 66d2619682b28eabaa5cb2e1858d4bdcaace2a6a Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sat, 21 Sep 2019 00:49:43 -0600 Subject: [PATCH] Remove std::bind from source --- source/base/quadrature_lib.cc | 7 +-- source/distributed/cell_weights.cc | 9 +-- source/distributed/solution_transfer.cc | 27 ++++----- source/dofs/dof_tools_constraints.cc | 57 +++++++++++------- source/fe/fe.cc | 7 +-- source/fe/fe_values.cc | 20 +++---- source/grid/grid_in.cc | 8 +-- source/grid/tria.cc | 54 +++++++---------- source/grid/tria_objects.cc | 6 +- source/lac/sparsity_pattern.cc | 4 +- source/multigrid/mg_transfer_block.cc | 18 +++--- source/multigrid/mg_transfer_component.cc | 6 +- source/numerics/data_out.cc | 22 ++++--- source/numerics/data_out_faces.cc | 28 ++++----- source/numerics/data_out_rotation.cc | 21 ++++--- source/numerics/derivative_approximation.cc | 24 ++++---- source/numerics/point_value_history.cc | 8 +-- source/numerics/time_dependent.cc | 44 +++++++------- source/particles/particle_handler.cc | 64 ++++++++++----------- 19 files changed, 215 insertions(+), 219 deletions(-) diff --git a/source/base/quadrature_lib.cc b/source/base/quadrature_lib.cc index a30e746619..bf30215277 100644 --- a/source/base/quadrature_lib.cc +++ b/source/base/quadrature_lib.cc @@ -774,10 +774,9 @@ QSorted::QSorted(const Quadrature &quad) std::sort(permutation.begin(), permutation.end(), - std::bind(&QSorted::compare_weights, - std::ref(*this), - std::placeholders::_1, - std::placeholders::_2)); + [this](const unsigned int x, const unsigned int y) { + return this->compare_weights(x, y); + }); // At this point, the variable is_tensor_product_flag is set // to the respective value of the given Quadrature in the base diff --git a/source/distributed/cell_weights.cc b/source/distributed/cell_weights.cc index cbd8891be2..0e92fa111c 100644 --- a/source/distributed/cell_weights.cc +++ b/source/distributed/cell_weights.cc @@ -40,10 +40,11 @@ namespace parallel // Add callback function to the cell_weight signal and store its // connection. tria_listener = triangulation->signals.cell_weight.connect( - std::bind(&CellWeights::weight_callback, - std::ref(*this), - std::placeholders::_1, - std::placeholders::_2)); + [this]( + const typename Triangulation::cell_iterator &cell_, + const typename Triangulation::CellStatus status) { + return this->weight_callback(cell_, status); + }); } else Assert( diff --git a/source/distributed/solution_transfer.cc b/source/distributed/solution_transfer.cc index 222884d101..fb45681fb8 100644 --- a/source/distributed/solution_transfer.cc +++ b/source/distributed/solution_transfer.cc @@ -156,11 +156,11 @@ namespace parallel Assert(tria != nullptr, ExcInternalError()); handle = tria->register_data_attach( - std::bind( - &SolutionTransfer::pack_callback, - this, - std::placeholders::_1, - std::placeholders::_2), + [this]( + const typename Triangulation:: + cell_iterator &cell_, + const typename Triangulation:: + CellStatus status) { return this->pack_callback(cell_, status); }, /*returns_variable_size_data=*/DoFHandlerType::is_hp_dof_handler); } @@ -262,14 +262,15 @@ namespace parallel tria->notify_ready_to_unpack( handle, - std::bind( - &SolutionTransfer::unpack_callback, - this, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3, - std::ref(all_out))); - + [this, &all_out]( + const typename Triangulation:: + cell_iterator &cell_, + const typename Triangulation:: + CellStatus status, + const boost::iterator_range::const_iterator> + &data_range) { + this->unpack_callback(cell_, status, data_range, all_out); + }); for (typename std::vector::iterator it = all_out.begin(); it != all_out.end(); diff --git a/source/dofs/dof_tools_constraints.cc b/source/dofs/dof_tools_constraints.cc index c4a250a428..b9ab377ea2 100644 --- a/source/dofs/dof_tools_constraints.cc +++ b/source/dofs/dof_tools_constraints.cc @@ -2819,25 +2819,38 @@ namespace DoFTools #endif } - WorkStream::run(coarse_grid.begin_active(), - coarse_grid.end(), - std::bind(&compute_intergrid_weights_3, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3, - coarse_component, - std::cref(coarse_grid.get_fe()), - std::cref(coarse_to_fine_grid_map), - std::cref(parameter_dofs)), - std::bind(©_intergrid_weights_3, - std::placeholders::_1, - coarse_component, - std::cref(coarse_grid.get_fe()), - std::cref(weight_mapping), - is_called_in_parallel, - std::ref(weights)), - scratch, - copy_data); + WorkStream::run( + coarse_grid.begin_active(), + coarse_grid.end(), + [coarse_component, + &coarse_grid, + &coarse_to_fine_grid_map, + ¶meter_dofs](const typename dealii::DoFHandler:: + active_cell_iterator & cell, + const Assembler::Scratch & scratch_data, + Assembler::CopyData ©_data) { + compute_intergrid_weights_3(cell, + scratch_data, + copy_data, + coarse_component, + coarse_grid.get_fe(), + coarse_to_fine_grid_map, + parameter_dofs); + }, + [coarse_component, + &coarse_grid, + &weight_mapping, + is_called_in_parallel, + &weights](const Assembler::CopyData ©_data) { + copy_intergrid_weights_3(copy_data, + coarse_component, + coarse_grid.get_fe(), + weight_mapping, + is_called_in_parallel, + weights); + }, + scratch, + copy_data); #ifdef DEAL_II_WITH_MPI for (std::size_t i = 0; @@ -3308,9 +3321,9 @@ namespace DoFTools const types::global_dof_index n_global_parm_dofs = std::count_if(weight_mapping.begin(), weight_mapping.end(), - std::bind(std::not_equal_to(), - std::placeholders::_1, - numbers::invalid_dof_index)); + [](const types::global_dof_index dof) { + return dof != numbers::invalid_dof_index; + }); // first construct the inverse mapping of weight_mapping std::vector inverse_weight_mapping( diff --git a/source/fe/fe.cc b/source/fe/fe.cc index adee8fbea5..24734dae81 100644 --- a/source/fe/fe.cc +++ b/source/fe/fe.cc @@ -83,10 +83,9 @@ FiniteElement::FiniteElement( , n_nonzero_components_table(compute_n_nonzero_components(nonzero_components)) , cached_primitivity(std::find_if(n_nonzero_components_table.begin(), n_nonzero_components_table.end(), - std::bind(std::not_equal_to(), - std::placeholders::_1, - 1U)) == - n_nonzero_components_table.end()) + [](const unsigned int n_components) { + return n_components != 1U; + }) == n_nonzero_components_table.end()) { Assert(restriction_is_additive_flags.size() == this->dofs_per_cell, ExcDimensionMismatch(restriction_is_additive_flags.size(), diff --git a/source/fe/fe_values.cc b/source/fe/fe_values.cc index 92e6ec1de3..4208da6368 100644 --- a/source/fe/fe_values.cc +++ b/source/fe/fe_values.cc @@ -4303,13 +4303,11 @@ FEValuesBase::maybe_invalidate_previous_present_cell( // triangulations invalidate_present_cell(); tria_listener_refinement = - cell->get_triangulation().signals.any_change.connect(std::bind( - &FEValuesBase::invalidate_present_cell, - std::ref(static_cast &>(*this)))); + cell->get_triangulation().signals.any_change.connect( + [this]() { this->invalidate_present_cell(); }); tria_listener_mesh_transform = - cell->get_triangulation().signals.mesh_movement.connect(std::bind( - &FEValuesBase::invalidate_present_cell, - std::ref(static_cast &>(*this)))); + cell->get_triangulation().signals.mesh_movement.connect( + [this]() { this->invalidate_present_cell(); }); } } else @@ -4318,13 +4316,11 @@ FEValuesBase::maybe_invalidate_previous_present_cell( // at least subscribe to the triangulation to get notified of // changes tria_listener_refinement = - cell->get_triangulation().signals.post_refinement.connect(std::bind( - &FEValuesBase::invalidate_present_cell, - std::ref(static_cast &>(*this)))); + cell->get_triangulation().signals.post_refinement.connect( + [this]() { this->invalidate_present_cell(); }); tria_listener_mesh_transform = - cell->get_triangulation().signals.mesh_movement.connect(std::bind( - &FEValuesBase::invalidate_present_cell, - std::ref(static_cast &>(*this)))); + cell->get_triangulation().signals.mesh_movement.connect( + [this]() { this->invalidate_present_cell(); }); } } diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc index b8cdce11b1..95d144eb4f 100644 --- a/source/grid/grid_in.cc +++ b/source/grid/grid_in.cc @@ -3155,11 +3155,9 @@ GridIn::skip_empty_lines(std::istream &in) // consists only of spaces, and // if not put the whole thing // back and return - if (std::find_if(line.begin(), - line.end(), - std::bind(std::not_equal_to(), - std::placeholders::_1, - ' ')) != line.end()) + if (std::find_if(line.begin(), line.end(), [](const char c) { + return c != ' '; + }) != line.end()) { in.putback('\n'); for (int i = line.length() - 1; i >= 0; --i) diff --git a/source/grid/tria.cc b/source/grid/tria.cc index a95f5c52e8..da64da1b3a 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -4737,10 +4737,10 @@ namespace internal // count number of used cells // on the next higher level - const unsigned int used_cells = std::count_if( - triangulation.levels[level + 1]->cells.used.begin(), - triangulation.levels[level + 1]->cells.used.end(), - std::bind(std::equal_to(), std::placeholders::_1, true)); + const unsigned int used_cells = + std::count(triangulation.levels[level + 1]->cells.used.begin(), + triangulation.levels[level + 1]->cells.used.end(), + true); // reserve space for the used_cells cells already existing // on the next higher level as well as for the @@ -4760,11 +4760,9 @@ namespace internal // add to needed vertices how many // vertices are already in use - needed_vertices += std::count_if(triangulation.vertices_used.begin(), - triangulation.vertices_used.end(), - std::bind(std::equal_to(), - std::placeholders::_1, - true)); + needed_vertices += std::count(triangulation.vertices_used.begin(), + triangulation.vertices_used.end(), + true); // if we need more vertices: create them, if not: leave the // array as is, since shrinking is not really possible because // some of the vertices at the end may be in use @@ -5046,10 +5044,10 @@ namespace internal // count number of used cells on the next higher level - const unsigned int used_cells = std::count_if( - triangulation.levels[level + 1]->cells.used.begin(), - triangulation.levels[level + 1]->cells.used.end(), - std::bind(std::equal_to(), std::placeholders::_1, true)); + const unsigned int used_cells = + std::count(triangulation.levels[level + 1]->cells.used.begin(), + triangulation.levels[level + 1]->cells.used.end(), + true); // reserve space for the used_cells cells already existing @@ -5085,11 +5083,9 @@ namespace internal triangulation.faces->lines.reserve_space(n_lines_in_pairs, 0); // add to needed vertices how many vertices are already in use - needed_vertices += std::count_if(triangulation.vertices_used.begin(), - triangulation.vertices_used.end(), - std::bind(std::equal_to(), - std::placeholders::_1, - true)); + needed_vertices += std::count(triangulation.vertices_used.begin(), + triangulation.vertices_used.end(), + true); // if we need more vertices: create them, if not: leave the // array as is, since shrinking is not really possible because // some of the vertices at the end may be in use @@ -5452,10 +5448,10 @@ namespace internal // count number of used cells on the next higher level - const unsigned int used_cells = std::count_if( - triangulation.levels[level + 1]->cells.used.begin(), - triangulation.levels[level + 1]->cells.used.end(), - std::bind(std::equal_to(), std::placeholders::_1, true)); + const unsigned int used_cells = + std::count(triangulation.levels[level + 1]->cells.used.begin(), + triangulation.levels[level + 1]->cells.used.end(), + true); // reserve space for the used_cells cells already existing @@ -5539,11 +5535,9 @@ namespace internal // add to needed vertices how many vertices are already in use - needed_vertices += std::count_if(triangulation.vertices_used.begin(), - triangulation.vertices_used.end(), - std::bind(std::equal_to(), - std::placeholders::_1, - true)); + needed_vertices += std::count(triangulation.vertices_used.begin(), + triangulation.vertices_used.end(), + true); // if we need more vertices: create them, if not: leave the // array as is, since shrinking is not really possible because // some of the vertices at the end may be in use @@ -13184,11 +13178,7 @@ template unsigned int Triangulation::n_used_vertices() const { - return std::count_if(vertices_used.begin(), - vertices_used.end(), - std::bind(std::equal_to(), - std::placeholders::_1, - true)); + return std::count(vertices_used.begin(), vertices_used.end(), true); } diff --git a/source/grid/tria_objects.cc b/source/grid/tria_objects.cc index 34a64e0baf..6e583bf967 100644 --- a/source/grid/tria_objects.cc +++ b/source/grid/tria_objects.cc @@ -170,11 +170,7 @@ namespace internal TriaObjectsHex::reserve_space(const unsigned int new_hexes) { const unsigned int new_size = - new_hexes + std::count_if(used.begin(), - used.end(), - std::bind(std::equal_to(), - std::placeholders::_1, - true)); + new_hexes + std::count(used.begin(), used.end(), true); // see above... if (new_size > cells.size()) diff --git a/source/lac/sparsity_pattern.cc b/source/lac/sparsity_pattern.cc index e573a1fb2a..9c3185dc74 100644 --- a/source/lac/sparsity_pattern.cc +++ b/source/lac/sparsity_pattern.cc @@ -352,9 +352,7 @@ SparsityPattern::compress() const std::size_t nonzero_elements = std::count_if(&colnums[rowstart[0]], &colnums[rowstart[rows]], - std::bind(std::not_equal_to(), - std::placeholders::_1, - invalid_entry)); + [](const size_type col) { return col != invalid_entry; }); // now allocate the respective memory std::unique_ptr new_colnums(new size_type[nonzero_elements]); diff --git a/source/multigrid/mg_transfer_block.cc b/source/multigrid/mg_transfer_block.cc index 02b305460e..72ac874f72 100644 --- a/source/multigrid/mg_transfer_block.cc +++ b/source/multigrid/mg_transfer_block.cc @@ -544,9 +544,9 @@ MGTransferBlockSelect::build_matrices( const types::global_dof_index n_active_dofs = std::count_if(temp_copy_indices.begin(), temp_copy_indices.end(), - std::bind(std::not_equal_to(), - std::placeholders::_1, - numbers::invalid_dof_index)); + [](const types::global_dof_index index) { + return index != numbers::invalid_dof_index; + }); copy_indices[selected_block][level].resize(n_active_dofs); types::global_dof_index counter = 0; for (types::global_dof_index i = 0; i < temp_copy_indices.size(); ++i) @@ -623,12 +623,12 @@ MGTransferBlock::build_matrices(const DoFHandler &dof, for (unsigned int block = 0; block < n_blocks; ++block) if (selected[block]) { - const types::global_dof_index n_active_dofs = std::count_if( - temp_copy_indices[block].begin(), - temp_copy_indices[block].end(), - std::bind(std::not_equal_to(), - std::placeholders::_1, - numbers::invalid_dof_index)); + const types::global_dof_index n_active_dofs = + std::count_if(temp_copy_indices[block].begin(), + temp_copy_indices[block].end(), + [](const types::global_dof_index index) { + return index != numbers::invalid_dof_index; + }); copy_indices[block][level].resize(n_active_dofs); types::global_dof_index counter = 0; for (types::global_dof_index i = 0; diff --git a/source/multigrid/mg_transfer_component.cc b/source/multigrid/mg_transfer_component.cc index fa61143924..69d149d844 100644 --- a/source/multigrid/mg_transfer_component.cc +++ b/source/multigrid/mg_transfer_component.cc @@ -683,9 +683,9 @@ MGTransferSelect::build_matrices( const types::global_dof_index n_active_dofs = std::count_if(temp_copy_indices.begin(), temp_copy_indices.end(), - std::bind(std::not_equal_to(), - std::placeholders::_1, - numbers::invalid_dof_index)); + [](const types::global_dof_index index) { + return index != numbers::invalid_dof_index; + }); copy_to_and_from_indices[level].resize(n_active_dofs); types::global_dof_index counter = 0; for (types::global_dof_index i = 0; i < temp_copy_indices.size(); ++i) diff --git a/source/numerics/data_out.cc b/source/numerics/data_out.cc index a76ae281cf..2feb97861f 100644 --- a/source/numerics/data_out.cc +++ b/source/numerics/data_out.cc @@ -812,15 +812,19 @@ DataOut::build_patches( WorkStream::run( all_cells.data(), all_cells.data() + all_cells.size(), - std::bind(&DataOut::build_one_patch, - this, - std::placeholders::_1, - std::placeholders::_2, - /* no std::placeholders::_3, since this function doesn't - actually need a copy data object -- it just writes everything - right into the output array */ - n_subdivisions, - curved_cell_region), + [this, n_subdivisions, curved_cell_region]( + const std::pair *cell_and_index, + internal::DataOutImplementation::ParallelData< + DoFHandlerType::dimension, + DoFHandlerType::space_dimension> &scratch_data, + // this function doesn't actually need a copy data object -- it just + // writes everything right into the output array + int) { + this->build_one_patch(cell_and_index, + scratch_data, + n_subdivisions, + curved_cell_region); + }, // no copy-local-to-global function needed here std::function(), thread_data, diff --git a/source/numerics/data_out_faces.cc b/source/numerics/data_out_faces.cc index 69bab08305..473b7af5d3 100644 --- a/source/numerics/data_out_faces.cc +++ b/source/numerics/data_out_faces.cc @@ -396,19 +396,21 @@ DataOutFaces::build_patches( n_datasets, Utilities::fixed_power(n_subdivisions + 1)); // now build the patches in parallel - WorkStream::run(all_faces.data(), - all_faces.data() + all_faces.size(), - std::bind(&DataOutFaces::build_one_patch, - this, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3), - std::bind(&internal::DataOutFacesImplementation:: - append_patch_to_list, - std::placeholders::_1, - std::ref(this->patches)), - thread_data, - sample_patch); + WorkStream::run( + all_faces.data(), + all_faces.data() + all_faces.size(), + [this](const FaceDescriptor *cell_and_face, + internal::DataOutFacesImplementation::ParallelData &data, + DataOutBase::Patch &patch) { + this->build_one_patch(cell_and_face, data, patch); + }, + [this](const DataOutBase::Patch &patch) { + internal::DataOutFacesImplementation:: + append_patch_to_list(patch, this->patches); + }, + thread_data, + sample_patch); } diff --git a/source/numerics/data_out_rotation.cc b/source/numerics/data_out_rotation.cc index 7819ad0ac3..c366af2289 100644 --- a/source/numerics/data_out_rotation.cc +++ b/source/numerics/data_out_rotation.cc @@ -535,15 +535,18 @@ DataOutRotation::build_patches( WorkStream::run( all_cells.data(), all_cells.data() + all_cells.size(), - std::bind(&DataOutRotation::build_one_patch, - this, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3), - std::bind(&internal::DataOutRotationImplementation :: - append_patch_to_list, - std::placeholders::_1, - std::ref(this->patches)), + [this](const cell_iterator *cell, + internal::DataOutRotationImplementation:: + ParallelData &data, + std::vector> + &my_patches) { this->build_one_patch(cell, data, my_patches); }, + [this]( + const std::vector> + &new_patches) { + internal::DataOutRotationImplementation :: + append_patch_to_list(new_patches, + this->patches); + }, thread_data, new_patches); } diff --git a/source/numerics/derivative_approximation.cc b/source/numerics/derivative_approximation.cc index 042512a15a..8c1928e072 100644 --- a/source/numerics/derivative_approximation.cc +++ b/source/numerics/derivative_approximation.cc @@ -1002,19 +1002,17 @@ namespace DerivativeApproximation WorkStream::run( begin, end, - static_cast const &, - Assembler::Scratch const &, - Assembler::CopyData &)>>( - std::bind(&approximate, - std::placeholders::_1, - std::cref(mapping), - std::cref(dof_handler), - std::cref(solution), - component)), + [&mapping, &dof_handler, &solution, component]( + SynchronousIterators const &cell, + Assembler::Scratch const &, + Assembler::CopyData &) { + approximate( + cell, mapping, dof_handler, solution, component); + }, std::function(), internal::Assembler::Scratch(), internal::Assembler::CopyData()); diff --git a/source/numerics/point_value_history.cc b/source/numerics/point_value_history.cc index 58c7d7a822..89445ff029 100644 --- a/source/numerics/point_value_history.cc +++ b/source/numerics/point_value_history.cc @@ -96,7 +96,7 @@ PointValueHistory::PointValueHistory( indep_names = std::vector(); tria_listener = dof_handler.get_triangulation().signals.any_change.connect( - std::bind(&PointValueHistory::tria_change_listener, std::ref(*this))); + [this]() { this->tria_change_listener(); }); } @@ -128,8 +128,7 @@ PointValueHistory::PointValueHistory( { tria_listener = dof_handler->get_triangulation().signals.any_change.connect( - std::bind(&PointValueHistory::tria_change_listener, - std::ref(*this))); + [this]() { this->tria_change_listener(); }); } } @@ -162,8 +161,7 @@ PointValueHistory::operator=(const PointValueHistory &point_value_history) { tria_listener = dof_handler->get_triangulation().signals.any_change.connect( - std::bind(&PointValueHistory::tria_change_listener, - std::ref(*this))); + [this]() { this->tria_change_listener(); }); } return *this; diff --git a/source/numerics/time_dependent.cc b/source/numerics/time_dependent.cc index 80a4533108..7860c418c0 100644 --- a/source/numerics/time_dependent.cc +++ b/source/numerics/time_dependent.cc @@ -169,33 +169,33 @@ TimeDependent::delete_timestep(const unsigned int position) void TimeDependent::solve_primal_problem() { - do_loop(std::bind(&TimeStepBase::init_for_primal_problem, - std::placeholders::_1), - std::bind(&TimeStepBase::solve_primal_problem, std::placeholders::_1), - timestepping_data_primal, - forward); + do_loop( + [](TimeStepBase *const time_step) { time_step->init_for_primal_problem(); }, + [](TimeStepBase *const time_step) { time_step->solve_primal_problem(); }, + timestepping_data_primal, + forward); } void TimeDependent::solve_dual_problem() { - do_loop(std::bind(&TimeStepBase::init_for_dual_problem, - std::placeholders::_1), - std::bind(&TimeStepBase::solve_dual_problem, std::placeholders::_1), - timestepping_data_dual, - backward); + do_loop( + [](TimeStepBase *const time_step) { time_step->init_for_dual_problem(); }, + [](TimeStepBase *const time_step) { time_step->init_for_dual_problem(); }, + timestepping_data_dual, + backward); } void TimeDependent::postprocess() { - do_loop(std::bind(&TimeStepBase::init_for_postprocessing, - std::placeholders::_1), - std::bind(&TimeStepBase::postprocess_timestep, std::placeholders::_1), - timestepping_data_postprocess, - forward); + do_loop( + [](TimeStepBase *const time_step) { time_step->init_for_postprocessing(); }, + [](TimeStepBase *const time_step) { time_step->postprocess_timestep(); }, + timestepping_data_postprocess, + forward); } @@ -227,13 +227,13 @@ TimeDependent::start_sweep(const unsigned int s) void TimeDependent::end_sweep() { - void (TimeDependent::*p)(const unsigned int, const unsigned int) = - &TimeDependent::end_sweep; - parallel::apply_to_subranges( - 0U, - timesteps.size(), - std::bind(p, this, std::placeholders::_1, std::placeholders::_2), - 1); + parallel::apply_to_subranges(0U, + timesteps.size(), + [this](const unsigned int begin, + const unsigned int end) { + this->end_sweep(begin, end); + }, + 1); } diff --git a/source/particles/particle_handler.cc b/source/particles/particle_handler.cc index 491f34e79d..95af0a1319 100644 --- a/source/particles/particle_handler.cc +++ b/source/particles/particle_handler.cc @@ -654,14 +654,17 @@ namespace Particles for (unsigned int i = 0; i < n_neighbor_cells; ++i) neighbor_permutation[i] = i; + const auto cell_centers = + vertex_to_cell_centers[closest_vertex_index]; std::sort(neighbor_permutation.begin(), neighbor_permutation.end(), - std::bind(&compare_particle_association, - std::placeholders::_1, - std::placeholders::_2, - std::cref(vertex_to_particle), - std::cref( - vertex_to_cell_centers[closest_vertex_index]))); + [&vertex_to_particle, &cell_centers](const unsigned int a, + const unsigned int b) { + return compare_particle_association(a, + b, + vertex_to_particle, + cell_centers); + }); // Search all of the cells adjacent to the closest vertex of the // previous cell Most likely we will find the particle in them. @@ -1078,14 +1081,13 @@ namespace Particles if (global_max_particles_per_cell > 0) { - const std::function( - const typename Triangulation::cell_iterator &, - const typename Triangulation::CellStatus)> - callback_function = - std::bind(&ParticleHandler::store_particles, - std::cref(*this), - std::placeholders::_1, - std::placeholders::_2); + const auto callback_function = + [this](const typename Triangulation::cell_iterator + &cell_iterator, + const typename Triangulation::CellStatus + cell_status) { + return this->store_particles(cell_iterator, cell_status); + }; handle = non_const_triangulation->register_data_attach( callback_function, /*returns_variable_size_data=*/true); @@ -1114,14 +1116,13 @@ namespace Particles // data correctly. Only do this if something was actually stored. if (serialization && (global_max_particles_per_cell > 0)) { - const std::function( - const typename Triangulation::cell_iterator &, - const typename Triangulation::CellStatus)> - callback_function = - std::bind(&ParticleHandler::store_particles, - std::cref(*this), - std::placeholders::_1, - std::placeholders::_2); + const auto callback_function = + [this](const typename Triangulation::cell_iterator + &cell_iterator, + const typename Triangulation::CellStatus + cell_status) { + return this->store_particles(cell_iterator, cell_status); + }; handle = non_const_triangulation->register_data_attach( callback_function, /*returns_variable_size_data=*/true); @@ -1130,16 +1131,15 @@ namespace Particles // Check if something was stored and load it if (handle != numbers::invalid_unsigned_int) { - const std::function::cell_iterator &, - const typename Triangulation::CellStatus, - const boost::iterator_range::const_iterator> &)> - callback_function = - std::bind(&ParticleHandler::load_particles, - std::ref(*this), - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3); + const auto callback_function = + [this]( + const typename Triangulation::cell_iterator + &cell_iterator, + const typename Triangulation::CellStatus cell_status, + const boost::iterator_range::const_iterator> + &range_iterator) { + this->load_particles(cell_iterator, cell_status, range_iterator); + }; non_const_triangulation->notify_ready_to_unpack(handle, callback_function); -- 2.39.5