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

Use rvalues for functions that take callables #1231

Merged
merged 1 commit into from
Aug 5, 2020
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 Src/Particle/AMReX_DenseBins.H
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public:
* \param f a function object that maps items to bins
*/
template <typename N, typename F>
void build (N nitems, T const* v, const Box& bx, F f)
void build (N nitems, T const* v, const Box& bx, F&& f)
{
BL_PROFILE("DenseBins<T>::build");

Expand Down
2 changes: 1 addition & 1 deletion Src/Particle/AMReX_NeighborList.H
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public:
template <class PTile, class CheckPair>
void build (PTile& ptile,
const amrex::Box& bx, const amrex::Geometry& geom,
CheckPair check_pair, int num_cells=1)
CheckPair&& check_pair, int num_cells=1)
{
auto& vec = ptile.GetArrayOfStructs()();
m_pstruct = vec.dataPtr();
Expand Down
2 changes: 1 addition & 1 deletion Src/Particle/AMReX_NeighborParticles.H
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public:
/// Build a Neighbor List for each tile
///
template <class CheckPair>
void buildNeighborList (CheckPair check_pair, bool sort=false);
void buildNeighborList (CheckPair&& check_pair, bool sort=false);

void printNeighborList ();

Expand Down
6 changes: 4 additions & 2 deletions Src/Particle/AMReX_NeighborParticlesI.H
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ template <int NStructReal, int NStructInt>
template <class CheckPair>
void
NeighborParticleContainer<NStructReal, NStructInt>::
buildNeighborList (CheckPair check_pair, bool sort)
buildNeighborList (CheckPair&& check_pair, bool sort)
{
AMREX_ASSERT(numParticlesOutOfRange(*this, m_num_neighbor_cells) == 0);

Expand Down Expand Up @@ -705,7 +705,9 @@ buildNeighborList (CheckPair check_pair, bool sort)
bx.coarsen(ref_fac);
bx.grow(m_num_neighbor_cells);

m_neighbor_list[lev][index].build(ptile, bx, geom, check_pair, m_num_neighbor_cells);
m_neighbor_list[lev][index].build(ptile, bx, geom,
std::forward<CheckPair>(check_pair),
m_num_neighbor_cells);
#ifndef AMREX_USE_GPU
const auto& counts = m_neighbor_list[lev][index].GetCounts();
const auto& list = m_neighbor_list[lev][index].GetList();
Expand Down
4 changes: 2 additions & 2 deletions Src/Particle/AMReX_ParticleCommunication.H
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ void packBuffer (const PC& pc, const ParticleCopyOp& op, const ParticleCopyPlan&

template <class PC, class Buffer, class UnpackPolicy,
EnableIf_t<IsParticleContainer<PC>::value, int> foo = 0>
void unpackBuffer (PC& pc, const ParticleCopyPlan& plan, const Buffer& snd_buffer, const UnpackPolicy policy)
void unpackBuffer (PC& pc, const ParticleCopyPlan& plan, const Buffer& snd_buffer, const UnpackPolicy&& policy)
{
BL_PROFILE("amrex::unpackBuffer");

Expand Down Expand Up @@ -502,7 +502,7 @@ void communicateParticlesFinish (const ParticleCopyPlan& plan);

template <class PC, class Buffer, class UnpackPolicy,
EnableIf_t<IsParticleContainer<PC>::value, int> foo = 0>
void unpackRemotes (PC& pc, const ParticleCopyPlan& plan, Buffer& rcv_buffer, const UnpackPolicy& policy)
void unpackRemotes (PC& pc, const ParticleCopyPlan& plan, Buffer& rcv_buffer, UnpackPolicy&& policy)
{
BL_PROFILE("amrex::unpackRemotes");

Expand Down
2 changes: 1 addition & 1 deletion Src/Particle/AMReX_SparseBins.H
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public:
* \param f a function object that maps items to bins
*/
template <typename N, typename F>
void build (N nitems, T const* v, const Box& bx, F f)
void build (N nitems, T const* v, const Box& bx, F&& f)
{
BL_PROFILE("SparseBins<T>::build");

Expand Down