Skip to content

Commit

Permalink
use enable_if to prevent wrong template from getting selected
Browse files Browse the repository at this point in the history
  • Loading branch information
atmyers committed Jul 25, 2023
1 parent 9c6e0a3 commit 3812a82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
6 changes: 4 additions & 2 deletions Src/Particle/AMReX_ParticleTransformation.H
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ int filterParticles (DstTile& dst, const SrcTile& src, Pred&& p) noexcept
* \param n the number of particles to apply the operation to
*
*/
template <typename DstTile, typename SrcTile, typename Pred, typename Index, typename N>
template <typename DstTile, typename SrcTile, typename Pred, typename Index, typename N,
std::enable_if_t<!std::is_pointer_v<std::decay_t<Pred>>,Index> = 0>
Index filterParticles (DstTile& dst, const SrcTile& src, Pred&& p,
Index src_start, Index dst_start, N n) noexcept
{
Expand Down Expand Up @@ -592,7 +593,8 @@ int filterAndTransformParticles (DstTile1& dst1, DstTile2& dst2, const SrcTile&
*
*/

template <typename DstTile, typename SrcTile, typename Pred, typename F, typename Index>
template <typename DstTile, typename SrcTile, typename Pred, typename F, typename Index,
std::enable_if_t<!std::is_pointer_v<std::decay_t<Pred>>,Index> = 0>
Index filterAndTransformParticles (DstTile& dst, const SrcTile& src, Pred&& p, F&& f,
Index src_start, Index dst_start) noexcept
{
Expand Down
16 changes: 0 additions & 16 deletions Src/Particle/AMReX_ParticleUtil.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,6 @@ namespace amrex

namespace particle_detail {

template <typename F, typename P>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
auto call_f (F const& f, P const& p, amrex::RandomEngine const& engine) noexcept
-> decltype(f(P{},RandomEngine{}))
{
return f(p,engine);
}

template <typename F, typename P>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
auto call_f (F const& f, P const& p, amrex::RandomEngine const&) noexcept
-> decltype(f(P{}))
{
return f(p);
}

// The next several functions are used by ParticleReduce

// Lambda takes a Particle
Expand Down

0 comments on commit 3812a82

Please sign in to comment.