diff --git a/.clang-tidy b/.clang-tidy index fc4fd05fa1b..f25a344b264 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -77,8 +77,6 @@ HeaderFilterRegex: '([^n].....|[^o]....|[^l]...|[^i]..|[^n].|[^t])\.H$' # Only available in clang-tidy >= 17 HeaderFileExtensions: ['', "H", 'h', 'hh', 'hpp', 'hxx'] -# We will try to modernize this after switching to C++20 -# -modernize-use-constraints # -modernize-use-designated-initializers # -modernize-use-std-numbers # -modernize-use-ranges diff --git a/Src/AmrCore/AMReX_AmrParticles.H b/Src/AmrCore/AMReX_AmrParticles.H index d4e798a5e32..e8bf2499401 100644 --- a/Src/AmrCore/AMReX_AmrParticles.H +++ b/Src/AmrCore/AMReX_AmrParticles.H @@ -183,7 +183,8 @@ ParticleContainer_impl::value, int> foo = 0> +template +requires IsParticleContainer::value void ParticleToMesh (PC const& pc, const Vector& mf, int lev_min, int lev_max, F&& f, diff --git a/Src/AmrCore/AMReX_FillPatchUtil.H b/Src/AmrCore/AMReX_FillPatchUtil.H index fab29231bf3..d252db042ff 100644 --- a/Src/AmrCore/AMReX_FillPatchUtil.H +++ b/Src/AmrCore/AMReX_FillPatchUtil.H @@ -37,13 +37,16 @@ namespace amrex template struct NullInterpHook { - template ::value,int> = 0> + template + requires IsBaseFab::value void operator() (MFFAB& /*fab*/, const Box& /*bx*/, int /*icomp*/, int /*ncomp*/) const {} - template ::value,int> = 0> + template + requires IsBaseFab::value void operator() (Array /*fab*/, const Box& /*bx*/, int /*icomp*/, int /*ncomp*/) const {} - template ::value,int> = 0> + template + requires IsFabArray::value void operator() (MFFAB& /*mf*/, int /*icomp*/, int /*ncomp*/) const {} }; @@ -88,7 +91,8 @@ namespace amrex * \param bcfcomp starting component for physbcf */ template - std::enable_if_t::value> + requires IsFabArray::value + void FillPatchSingleLevel (MF& mf, IntVect const& nghost, Real time, const Vector& smf, const Vector& stime, int scomp, int dcomp, int ncomp, @@ -119,7 +123,8 @@ namespace amrex * \param bcfcomp starting component for physbcf */ template - std::enable_if_t::value> + requires IsFabArray::value + void FillPatchSingleLevel (MF& mf, Real time, const Vector& smf, const Vector& stime, int scomp, int dcomp, int ncomp, @@ -167,7 +172,8 @@ namespace amrex template , typename PostInterpHook=NullInterpHook > - std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (MF& mf, IntVect const& nghost, Real time, const Vector& cmf, const Vector& ct, const Vector& fmf, const Vector& ft, @@ -221,7 +227,8 @@ namespace amrex template , typename PostInterpHook=NullInterpHook > - std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (MF& mf, Real time, const Vector& cmf, const Vector& ct, const Vector& fmf, const Vector& ft, @@ -279,7 +286,8 @@ namespace amrex template , typename PostInterpHook=NullInterpHook > - std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (Array const& mf, IntVect const& nghost, Real time, const Vector >& cmf, const Vector& ct, const Vector >& fmf, const Vector& ft, @@ -337,7 +345,8 @@ namespace amrex template , typename PostInterpHook=NullInterpHook > - std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (Array const& mf, IntVect const& nghost, Real time, const Vector >& cmf, const Vector& ct, const Vector >& fmf, const Vector& ft, @@ -394,7 +403,8 @@ namespace amrex template , typename PostInterpHook=NullInterpHook > - std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (Array const& mf, Real time, const Vector >& cmf, const Vector& ct, const Vector >& fmf, const Vector& ft, @@ -449,7 +459,8 @@ namespace amrex * \param post_interp post-interpolation hook */ template - std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (MF& mf, IntVect const& nghost, Real time, const EB2::IndexSpace& index_space, const Vector& cmf, const Vector& ct, @@ -503,7 +514,8 @@ namespace amrex * \param post_interp post-interpolation hook */ template - std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (MF& mf, Real time, const EB2::IndexSpace& index_space, const Vector& cmf, const Vector& ct, @@ -552,7 +564,8 @@ namespace amrex template , typename PostInterpHook=NullInterpHook > - std::enable_if_t::value> + requires IsFabArray::value + void InterpFromCoarseLevel (MF& mf, Real time, const MF& cmf, int scomp, int dcomp, int ncomp, const Geometry& cgeom, const Geometry& fgeom, @@ -596,7 +609,8 @@ namespace amrex template , typename PostInterpHook=NullInterpHook > - std::enable_if_t::value> + requires IsFabArray::value + void InterpFromCoarseLevel (MF& mf, IntVect const& nghost, Real time, const MF& cmf, int scomp, int dcomp, int ncomp, const Geometry& cgeom, const Geometry& fgeom, @@ -641,7 +655,8 @@ namespace amrex template , typename PostInterpHook=NullInterpHook > - std::enable_if_t::value> + requires IsFabArray::value + void InterpFromCoarseLevel (MF& mf, IntVect const& nghost, Real time, const EB2::IndexSpace* index_space, const MF& cmf, int scomp, int dcomp, int ncomp, @@ -687,7 +702,8 @@ namespace amrex template , typename PostInterpHook=NullInterpHook > - std::enable_if_t::value> + requires IsFabArray::value + void InterpFromCoarseLevel (Array const& mf, Real time, const Array& cmf, int scomp, int dcomp, int ncomp, const Geometry& cgeom, const Geometry& fgeom, @@ -733,7 +749,8 @@ namespace amrex template , typename PostInterpHook=NullInterpHook > - std::enable_if_t::value> + requires IsFabArray::value + void InterpFromCoarseLevel (Array const& mf, IntVect const& nghost, Real time, const Array& cmf, int scomp, int dcomp, int ncomp, const Geometry& cgeom, const Geometry& fgeom, @@ -772,7 +789,8 @@ namespace amrex * \param bcscomp starting component for bcs */ template - std::enable_if_t::value> + requires IsFabArray::value + void InterpFromCoarseLevel (MF& mf, IntVect const& nghost, IntVect const& nghost_outside_domain, const MF& cmf, int scomp, int dcomp, int ncomp, @@ -803,7 +821,8 @@ namespace amrex * \param geom Geometry for this level */ template - std::enable_if_t::value> + requires IsFabArray::value + void FillPatchSingleLevel (MF& mf, IntVect const& nghost, Real time, const Vector& smf, IntVect const& snghost, const Vector& stime, int scomp, int dcomp, int ncomp, @@ -840,7 +859,8 @@ namespace amrex * \param bcscomp starting component for bcs */ template - std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (MF& mf, IntVect const& nghost, IntVect const& nghost_outside_domain, Real time, const Vector& cmf, const Vector& ct, @@ -905,7 +925,8 @@ namespace amrex * \param bcrcomp starting component for bcr */ template - std::enable_if_t::value> + requires IsFabArray::value + void FillPatchNLevels (MF& mf, int level, const IntVect& nghost, Real time, const Vector>& smf, const Vector>& st, int scomp, int dcomp, int ncomp, diff --git a/Src/AmrCore/AMReX_FillPatchUtil_I.H b/Src/AmrCore/AMReX_FillPatchUtil_I.H index 593f0edee4a..24f60829307 100644 --- a/Src/AmrCore/AMReX_FillPatchUtil_I.H +++ b/Src/AmrCore/AMReX_FillPatchUtil_I.H @@ -58,8 +58,10 @@ bool ProperlyNested (const IntVect& ratio, const IntVect& blocking_factor, int n return crse_box.contains(fine_box_coarsened); } +/// \cond DOXYGEN_IGNORE template -std::enable_if_t::value> +requires IsFabArray::value +void FillPatchSingleLevel (MF& mf, Real time, const Vector& smf, const Vector& stime, int scomp, int dcomp, int ncomp, @@ -71,7 +73,8 @@ FillPatchSingleLevel (MF& mf, Real time, } template -std::enable_if_t::value> +requires IsFabArray::value +void FillPatchSingleLevel (MF& mf, IntVect const& nghost, Real time, const Vector& smf, const Vector& stime, int scomp, int dcomp, int ncomp, @@ -193,6 +196,7 @@ FillPatchSingleLevel (MF& mf, IntVect const& nghost, Real time, physbcf(mf, dcomp, ncomp, nghost, time, bcfcomp); } +/// \endcond /** * \brief Helper that applies a MFInterpolater to fill a fine patch from a coarse patch. @@ -217,7 +221,8 @@ void FillPatchInterp (MultiFab& mf_fine_patch, int fcomp, MultiFab const& mf_crs MFInterpolater* mapper, const Vector& bcs, int bcscomp); template -std::enable_if_t::value && !std::is_same_v> +requires (IsFabArray::value) && (!std::is_same_v) +void FillPatchInterp (MF& mf_fine_patch, int fcomp, MF const& mf_crse_patch, int ccomp, int ncomp, IntVect const& ng, const Geometry& cgeom, const Geometry& fgeom, Box const& dest_domain, const IntVect& ratio, @@ -248,7 +253,8 @@ FillPatchInterp (MF& mf_fine_patch, int fcomp, MF const& mf_crse_patch, int ccom } template -std::enable_if_t::value> +requires IsFabArray::value +void FillPatchInterp (MF& mf_fine_patch, int fcomp, MF const& mf_crse_patch, int ccomp, int ncomp, IntVect const& ng, const Geometry& cgeom, const Geometry& fgeom, Box const& dest_domain, const IntVect& ratio, @@ -268,7 +274,8 @@ FillPatchInterp (MF& mf_fine_patch, int fcomp, MF const& mf_crse_patch, int ccom } template -std::enable_if_t::value && !std::is_same_v> +requires (IsFabArray::value) && (!std::is_same_v) +void InterpFace (Interp *interp, MF const& mf_crse_patch, int crse_comp, MF& mf_refined_patch, int fine_comp, @@ -294,7 +301,8 @@ InterpFace (Interp *interp, } template -std::enable_if_t::value> +requires IsFabArray::value +void InterpFace (InterpBase *interp, MF const& mf_crse_patch, int crse_comp, MF& mf_refined_patch, int fine_comp, @@ -326,10 +334,8 @@ namespace detail { // ======== FArrayBox - template , - int> = 0> + template + requires std::is_same_v MF make_mf_crse_patch (FabArrayBase::FPinfo const& fpc, int ncomp) { MF mf_crse_patch(fpc.ba_crse_patch, fpc.dm_patch, ncomp, 0, MFInfo(), @@ -337,10 +343,8 @@ namespace detail { return mf_crse_patch; } - template , - int> = 0> + template + requires std::is_same_v MF make_mf_crse_patch (FabArrayBase::FPinfo const& fpc, int ncomp, IndexType idx_type) { MF mf_crse_patch(amrex::convert(fpc.ba_crse_patch, idx_type), fpc.dm_patch, @@ -348,10 +352,8 @@ namespace detail { return mf_crse_patch; } - template , - int> = 0> + template + requires std::is_same_v MF make_mf_fine_patch (FabArrayBase::FPinfo const& fpc, int ncomp) { MF mf_fine_patch(fpc.ba_fine_patch, fpc.dm_patch, ncomp, 0, MFInfo(), @@ -359,10 +361,8 @@ namespace detail { return mf_fine_patch; } - template , - int> = 0> + template + requires std::is_same_v MF make_mf_fine_patch (FabArrayBase::FPinfo const& fpc, int ncomp, IndexType idx_type) { MF mf_fine_patch(amrex::convert(fpc.ba_fine_patch, idx_type), fpc.dm_patch, @@ -370,10 +370,8 @@ namespace detail { return mf_fine_patch; } - template , - int> = 0> + template + requires std::is_same_v MF make_mf_refined_patch (FabArrayBase::FPinfo const& fpc, int ncomp, IndexType idx_type, IntVect ratio) { MF mf_refined_patch(amrex::convert( amrex::refine( amrex::coarsen(fpc.ba_fine_patch, ratio), ratio), idx_type), @@ -381,10 +379,8 @@ namespace detail { return mf_refined_patch; } - template , - int> = 0> + template + requires std::is_same_v MF make_mf_crse_mask (FabArrayBase::FPinfo const& fpc, int ncomp, IndexType idx_type, IntVect ratio) { MF mf_crse_mask(amrex::convert(amrex::coarsen(fpc.ba_fine_patch, ratio), idx_type), @@ -392,10 +388,8 @@ namespace detail { return mf_crse_mask; } - template , - int> = 0> + template + requires std::is_same_v void mf_set_domain_bndry (MF &mf, Geometry const & geom) { mf.setDomainBndry(std::numeric_limits::quiet_NaN(), geom); @@ -404,71 +398,58 @@ namespace detail { // ======== Not FArrayBox - template , - int> = 0> + template + requires (!std::is_same_v) MF make_mf_crse_patch (FabArrayBase::FPinfo const& fpc, int ncomp) { return MF(fpc.ba_crse_patch, fpc.dm_patch, ncomp, 0); } - template , - int> = 0> + template + requires (!std::is_same_v) MF make_mf_crse_patch (FabArrayBase::FPinfo const& fpc, int ncomp, IndexType idx_type) { return MF(amrex::convert(fpc.ba_crse_patch, idx_type), fpc.dm_patch, ncomp, 0); } - template , - int> = 0> + template + requires (!std::is_same_v) MF make_mf_fine_patch (FabArrayBase::FPinfo const& fpc, int ncomp) { return MF(fpc.ba_fine_patch, fpc.dm_patch, ncomp, 0); } - template , - int> = 0> + template + requires (!std::is_same_v) MF make_mf_fine_patch (FabArrayBase::FPinfo const& fpc, int ncomp, IndexType idx_type) { return MF(amrex::convert(fpc.ba_fine_patch, idx_type), fpc.dm_patch, ncomp, 0); } - template , - int> = 0> + template + requires (!std::is_same_v) MF make_mf_refined_patch (FabArrayBase::FPinfo const& fpc, int ncomp, IndexType idx_type, IntVect ratio) { return MF(amrex::convert( amrex::refine( amrex::coarsen(fpc.ba_fine_patch, ratio), ratio), idx_type), fpc.dm_patch, ncomp, 0); } - template , - int> = 0> + template + requires (!std::is_same_v) MF make_mf_crse_mask (FabArrayBase::FPinfo const& fpc, int ncomp, IndexType idx_type, IntVect ratio) { return MF(amrex::convert(amrex::coarsen(fpc.ba_fine_patch, ratio), idx_type), fpc.dm_patch, ncomp, 0); } - template , - int> = 0> + template + requires (!std::is_same_v) void mf_set_domain_bndry (MF &/*mf*/, Geometry const & /*geom*/) { // nothing } template - std::enable_if_t::value,int> + requires IsFabArray::value + int FillPatchTwoLevels_doit (MF& mf, IntVect const& nghost, Real time, const Vector& cmf, const Vector& ct, const Vector& fmf, const Vector& ft, @@ -641,7 +622,8 @@ namespace detail { } template - std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels_doit (Array const& mf, IntVect const& nghost, Real time, const Vector >& cmf, const Vector& ct, const Vector >& fmf, const Vector& ft, @@ -812,8 +794,10 @@ namespace detail { } // namespace detail /// \endcond +/// \cond DOXYGEN_IGNORE template -std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (MF& mf, IntVect const& nghost, Real time, const Vector& cmf, const Vector& ct, const Vector& fmf, const Vector& ft, @@ -839,7 +823,8 @@ FillPatchTwoLevels (MF& mf, IntVect const& nghost, Real time, } template -std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (MF& mf, Real time, const Vector& cmf, const Vector& ct, const Vector& fmf, const Vector& ft, @@ -866,7 +851,8 @@ FillPatchTwoLevels (MF& mf, Real time, } template -std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (Array const& mf, IntVect const& nghost, Real time, const Vector >& cmf, const Vector& ct, const Vector >& fmf, const Vector& ft, @@ -893,7 +879,8 @@ FillPatchTwoLevels (Array const& mf, IntVect const& nghost, } template -std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (Array const& mf, IntVect const& nghost, Real time, const Vector >& cmf, const Vector& ct, const Vector >& fmf, const Vector& ft, @@ -924,7 +911,8 @@ FillPatchTwoLevels (Array const& mf, IntVect const& nghost, } template -std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (Array const& mf, Real time, const Vector >& cmf, const Vector& ct, const Vector >& fmf, const Vector& ft, @@ -956,7 +944,8 @@ FillPatchTwoLevels (Array const& mf, Real time, #ifdef AMREX_USE_EB template -std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (MF& mf, IntVect const& nghost, Real time, const EB2::IndexSpace& index_space, const Vector& cmf, const Vector& ct, @@ -978,7 +967,8 @@ FillPatchTwoLevels (MF& mf, IntVect const& nghost, Real time, } template -std::enable_if_t::value> + requires IsFabArray::value + void FillPatchTwoLevels (MF& mf, Real time, const EB2::IndexSpace& index_space, const Vector& cmf, const Vector& ct, @@ -1001,7 +991,8 @@ FillPatchTwoLevels (MF& mf, Real time, #endif template -std::enable_if_t::value> + requires IsFabArray::value + void InterpFromCoarseLevel (MF& mf, Real time, const MF& cmf, int scomp, int dcomp, int ncomp, const Geometry& cgeom, const Geometry& fgeom, @@ -1025,7 +1016,8 @@ InterpFromCoarseLevel (MF& mf, Real time, } template -std::enable_if_t::value> + requires IsFabArray::value + void InterpFromCoarseLevel (Array const& mf, Real time, const Array& cmf, int scomp, int dcomp, int ncomp, const Geometry& cgeom, const Geometry& fgeom, @@ -1043,7 +1035,8 @@ InterpFromCoarseLevel (Array const& mf, Real time, } template -std::enable_if_t::value> + requires IsFabArray::value + void InterpFromCoarseLevel (MF& mf, IntVect const& nghost, Real time, const MF& cmf, int scomp, int dcomp, int ncomp, const Geometry& cgeom, const Geometry& fgeom, @@ -1067,7 +1060,8 @@ InterpFromCoarseLevel (MF& mf, IntVect const& nghost, Real time, } template -std::enable_if_t::value> + requires IsFabArray::value + void InterpFromCoarseLevel (MF& mf, IntVect const& nghost, Real time, const EB2::IndexSpace* index_space, const MF& cmf, int scomp, int dcomp, int ncomp, @@ -1163,7 +1157,8 @@ InterpFromCoarseLevel (MF& mf, IntVect const& nghost, Real time, } template -std::enable_if_t::value> + requires IsFabArray::value + void InterpFromCoarseLevel (Array const& mf, IntVect const& nghost, Real time, const Array& cmf, int scomp, int dcomp, int ncomp, const Geometry& cgeom, const Geometry& fgeom, @@ -1313,7 +1308,8 @@ InterpFromCoarseLevel (Array const& mf, IntVect const& ngho } template -std::enable_if_t::value> +requires IsFabArray::value +void InterpFromCoarseLevel (MF& mf, IntVect const& nghost, IntVect const& nghost_outside_domain, const MF& cmf, int scomp, int dcomp, int ncomp, @@ -1328,7 +1324,8 @@ InterpFromCoarseLevel (MF& mf, IntVect const& nghost, } template -std::enable_if_t::value> +requires IsFabArray::value +void FillPatchSingleLevel (MF& mf, IntVect const& nghost, Real time, const Vector& smf, IntVect const& snghost, const Vector& stime, int scomp, int dcomp, int ncomp, @@ -1340,7 +1337,8 @@ FillPatchSingleLevel (MF& mf, IntVect const& nghost, Real time, } template -std::enable_if_t::value> +requires IsFabArray::value +void FillPatchTwoLevels (MF& mf, IntVect const& nghost, IntVect const& nghost_outside_domain, Real time, const Vector& cmf, const Vector& ct, @@ -1359,7 +1357,8 @@ FillPatchTwoLevels (MF& mf, IntVect const& nghost, } template -std::enable_if_t::value> +requires IsFabArray::value +void FillPatchNLevels (MF& mf, int level, const IntVect& nghost, Real time, const Vector>& smf, const Vector>& st, int scomp, int dcomp, int ncomp, @@ -1538,6 +1537,7 @@ FillPatchNLevels (MF& mf, int level, const IntVect& nghost, Real time, hook, hook, index_space); } } +/// \endcond } diff --git a/Src/Base/AMReX_BaseFab.H b/Src/Base/AMReX_BaseFab.H index 05f13fd6464..9d36c428134 100644 --- a/Src/Base/AMReX_BaseFab.H +++ b/Src/Base/AMReX_BaseFab.H @@ -95,13 +95,14 @@ makeArray4 (T* p, Box const& bx, int ncomp) noexcept } template -std::enable_if_t> +requires std::is_arithmetic_v +void placementNew (T* const /*ptr*/, Long /*n*/) {} template -std::enable_if_t - && !std::is_arithmetic_v> +requires (std::is_trivially_default_constructible_v) && (!std::is_arithmetic_v) +void placementNew (T* const ptr, Long n) { for (Long i = 0; i < n; ++i) { @@ -110,7 +111,8 @@ placementNew (T* const ptr, Long n) } template -std::enable_if_t> +requires (!std::is_trivially_default_constructible_v) +void placementNew (T* const ptr, Long n) { AMREX_HOST_DEVICE_FOR_1D ( n, i, @@ -120,12 +122,14 @@ placementNew (T* const ptr, Long n) } template -std::enable_if_t> +requires std::is_trivially_destructible_v +void placementDelete (T* const /*ptr*/, Long /*n*/) {} template -std::enable_if_t> +requires (!std::is_trivially_destructible_v) +void placementDelete (T* const ptr, Long n) { AMREX_HOST_DEVICE_FOR_1D (n, i, @@ -253,7 +257,8 @@ public: */ void resize (const Box& b, int N = 1, Arena* ar = nullptr); - template ,int> = 0> + template + requires std::is_trivially_destructible_v [[nodiscard]] Elixir elixir () noexcept; /** @@ -462,7 +467,8 @@ public: void getVal (T* data, const IntVect& pos) const noexcept; template || std::is_same_v,int> FOO = 0> + class U=T> + requires (std::is_same_v) || (std::is_same_v) void fill_snan () noexcept; /** @@ -1370,8 +1376,8 @@ BaseFab::shiftHalf (int idir, int n_cell) noexcept } template -template || std::is_same_v, int> FOO> +template +requires (std::is_same_v) || (std::is_same_v) void BaseFab::fill_snan () noexcept { @@ -1666,7 +1672,8 @@ BaseFab::resize (const Box& b, int n, Arena* ar) } template -template ,int>> +template +requires std::is_trivially_destructible_v Elixir BaseFab::elixir () noexcept { @@ -2848,8 +2855,8 @@ BaseFab::plus (const BaseFab& src, const Box& srcbox, const Box& destbox, namespace detail { -template ::value,int> FOO = 0> +template +requires HasAtomicAdd::value void basefab_atomic_add (BaseFab& dfab, const BaseFab& sfab, const Box& srcbox, const Box& destbox, int srccomp, int destcomp, int numcomp) noexcept @@ -2866,8 +2873,8 @@ void basefab_atomic_add (BaseFab& dfab, const BaseFab& sfab, }); } -template ::value,int> FOO = 0> +template +requires (!HasAtomicAdd::value) void basefab_atomic_add (BaseFab& dfab, const BaseFab& sfab, const Box& srcbox, const Box& destbox, int srccomp, int destcomp, int numcomp) diff --git a/Src/Base/AMReX_MFParallelFor.H b/Src/Base/AMReX_MFParallelFor.H index 917cfc4873d..fe418d1939d 100644 --- a/Src/Base/AMReX_MFParallelFor.H +++ b/Src/Base/AMReX_MFParallelFor.H @@ -39,7 +39,8 @@ struct DynamicTiling { * for x, y, and z-directions. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, F&& f) { detail::ParallelFor_doit(mf, IntVect(0), FabArrayBase::mfiter_tile_size, false, std::forward(f)); @@ -62,7 +63,8 @@ ParallelFor (MF const& mf, F&& f) * for x, y, and z-directions. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, F&& f) { #ifdef AMREX_USE_GPU @@ -89,7 +91,8 @@ ParallelFor (MF const& mf, F&& f) * for x, y, and z-directions. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, IntVect const& ng, F&& f) { detail::ParallelFor_doit(mf, ng, FabArrayBase::mfiter_tile_size, false, std::forward(f)); @@ -113,7 +116,8 @@ ParallelFor (MF const& mf, IntVect const& ng, F&& f) * for x, y, and z-directions. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, IntVect const& ng, F&& f) { #ifdef AMREX_USE_GPU @@ -141,7 +145,8 @@ ParallelFor (MF const& mf, IntVect const& ng, F&& f) * for x, y, and z-directions, and the last is for component. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, IntVect const& ng, int ncomp, F&& f) { detail::ParallelFor_doit(mf, ng, ncomp, FabArrayBase::mfiter_tile_size, false, std::forward(f)); @@ -166,7 +171,8 @@ ParallelFor (MF const& mf, IntVect const& ng, int ncomp, F&& f) * for x, y, and z-directions, and the last is for component. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, IntVect const& ng, int ncomp, F&& f) { #ifdef AMREX_USE_GPU @@ -194,7 +200,8 @@ ParallelFor (MF const& mf, IntVect const& ng, int ncomp, F&& f) * for x, y, and z-directions. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, TileSize const& ts, F&& f) { detail::ParallelFor_doit(mf, IntVect(0), ts.tile_size, false, std::forward(f)); @@ -219,7 +226,8 @@ ParallelFor (MF const& mf, TileSize const& ts, F&& f) * for x, y, and z-directions. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, TileSize const& ts, F&& f) { #ifdef AMREX_USE_GPU @@ -248,7 +256,8 @@ ParallelFor (MF const& mf, TileSize const& ts, F&& f) * for x, y, and z-directions. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, F&& f) { detail::ParallelFor_doit(mf, ng, ts.tile_size, false, std::forward(f)); @@ -274,7 +283,8 @@ ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, F&& f) * for x, y, and z-directions. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, F&& f) { #ifdef AMREX_USE_GPU @@ -304,7 +314,8 @@ ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, F&& f) * for x, y, and z-directions, and the last is for component. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts, F&& f) { detail::ParallelFor_doit(mf, ng, ncomp, ts.tile_size, false, std::forward(f)); @@ -331,7 +342,8 @@ ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts, F&& * for x, y, and z-directions, and the last is for component. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts, F&& f) { #ifdef AMREX_USE_GPU @@ -361,7 +373,8 @@ ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts, F&& * for x, y, and z-directions. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, DynamicTiling dt, F&& f) { detail::ParallelFor_doit(mf, ng, ts.tile_size, dt.dynamic, std::forward(f)); @@ -388,7 +401,8 @@ ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, DynamicTiling * for x, y, and z-directions, and the last is for component. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts, DynamicTiling dt, F&& f) { @@ -416,7 +430,8 @@ ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts, * for x, y, and z-directions. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, DynamicTiling dt, F&& f) { @@ -449,7 +464,8 @@ ParallelFor (MF const& mf, IntVect const& ng, TileSize const& ts, * for x, y, and z-directions, and the last is for component. */ template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor (MF const& mf, IntVect const& ng, int ncomp, TileSize const& ts, DynamicTiling dt, F&& f) { diff --git a/Src/Base/AMReX_MFParallelForG.H b/Src/Base/AMReX_MFParallelForG.H index eb588ab678d..e04bd932d4d 100644 --- a/Src/Base/AMReX_MFParallelForG.H +++ b/Src/Base/AMReX_MFParallelForG.H @@ -56,7 +56,8 @@ namespace parfor_mf_detail { } template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor_doit (MF const& mf, IntVect const& nghost, int ncomp, IntVect const&, bool, F const& f) { const auto& index_array = mf.IndexArray(); @@ -107,7 +108,8 @@ ParallelFor_doit (MF const& mf, IntVect const& nghost, int ncomp, IntVect const& } template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor_doit (MF const& mf, IntVect const& nghost, int ncomp, IntVect const& ts, bool dynamic, F&& f) { #ifdef AMREX_USE_CUDA @@ -119,7 +121,8 @@ ParallelFor_doit (MF const& mf, IntVect const& nghost, int ncomp, IntVect const& } template -std::enable_if_t::value> +requires IsFabArray::value +void ParallelFor_doit (MF const& mf, IntVect const& nghost, IntVect const& ts, bool dynamic, F&& f) { #ifdef AMREX_USE_CUDA diff --git a/Src/Base/AMReX_TagParallelFor.H b/Src/Base/AMReX_TagParallelFor.H index 240b35f7031..e381af1dcca 100644 --- a/Src/Base/AMReX_TagParallelFor.H +++ b/Src/Base/AMReX_TagParallelFor.H @@ -126,30 +126,34 @@ struct CommSendBufTag { // for packing send buffer namespace detail { template - std::enable_if_t().box())>, Box>, Long> + Long get_tag_size (T const& tag) noexcept + requires (std::is_same_v().box())>, Box>) { AMREX_ASSERT(tag.box().numPts() < Long(std::numeric_limits::max())); return static_cast(tag.box().numPts()); } template - std::enable_if_t().size())> >, Long> + Long get_tag_size (T const& tag) noexcept + requires (std::is_integral_v().size())> >) { AMREX_ASSERT(tag.size() < Long(std::numeric_limits::max())); return tag.size(); } template - constexpr - std::enable_if_t().box())>, Box>, bool> - is_box_tag (T const&) { return true; } + constexpr bool + is_box_tag (T const&) + requires (std::is_same_v().box())>, Box>) + { return true; } template - constexpr - std::enable_if_t().size())> >, bool> - is_box_tag (T const&) { return false; } + constexpr bool + is_box_tag (T const&) + requires (std::is_integral_v().size())> >) + { return false; } } /// \endcond @@ -311,8 +315,9 @@ namespace detail { template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE -std::enable_if_t().box())>, Box>, void> +void tagparfor_call_f (int icell, T const& tag, F&& f) noexcept + requires (std::is_same_v().box())>, Box>) { int ncells = tag.box().numPts(); const auto len = amrex::length(tag.box()); @@ -328,8 +333,9 @@ tagparfor_call_f (int icell, T const& tag, F&& f) noexcept template AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE -std::enable_if_t().size())> >, void> +void tagparfor_call_f (int i, T const& tag, F&& f) noexcept + requires (std::is_integral_v().size())> >) { int N = tag.size(); f(i, N, tag); @@ -434,8 +440,9 @@ ParallelFor_doit (TagVector const& tv, F const& f) /// \endcond template -std::enable_if_t().box())>, Box>> +void ParallelFor (TagVector const& tv, int ncomp, F const& f) + requires (std::is_same_v().box())>, Box>) { detail::ParallelFor_doit(tv, [=] AMREX_GPU_DEVICE ( @@ -450,8 +457,9 @@ ParallelFor (TagVector const& tv, int ncomp, F const& f) } template -std::enable_if_t().box())>, Box>, void> +void ParallelFor (TagVector const& tv, F const& f) + requires (std::is_same_v().box())>, Box>) { detail::ParallelFor_doit(tv, [=] AMREX_GPU_DEVICE ( @@ -464,8 +472,9 @@ ParallelFor (TagVector const& tv, F const& f) } template -std::enable_if_t().size())> >, void> +void ParallelFor (TagVector const& tv, F const& f) + requires (std::is_integral_v().size())> >) { detail::ParallelFor_doit(tv, [=] AMREX_GPU_DEVICE ( @@ -478,24 +487,27 @@ ParallelFor (TagVector const& tv, F const& f) } template -std::enable_if_t().box())>, Box>> +void ParallelFor (Vector const& tags, int ncomp, F && f) + requires (std::is_same_v().box())>, Box>) { TagVector tv{tags}; ParallelFor(tv, ncomp, std::forward(f)); } template -std::enable_if_t().box())>, Box>, void> +void ParallelFor (Vector const& tags, F && f) + requires (std::is_same_v().box())>, Box>) { TagVector tv{tags}; ParallelFor(tv, std::forward(f)); } template -std::enable_if_t().size())> >, void> +void ParallelFor (Vector const& tags, F && f) + requires (std::is_integral_v().size())> >) { TagVector tv{tags}; ParallelFor(tv, std::forward(f)); diff --git a/Src/Extern/HYPRE/AMReX_HypreSolver.H b/Src/Extern/HYPRE/AMReX_HypreSolver.H index bade1b0daf3..0fb49b20501 100644 --- a/Src/Extern/HYPRE/AMReX_HypreSolver.H +++ b/Src/Extern/HYPRE/AMReX_HypreSolver.H @@ -68,9 +68,9 @@ public: int a_verbose = 0, std::string a_options_namespace = "hypre"); - template ::value && - std::is_same_v, int> = 0> + template + requires IsFabArray::value && + std::is_same_v /** * \brief Solve Ax=b after the constructor assembled the IJ matrix. * @@ -106,11 +106,11 @@ public: */ template #ifdef AMREX_USE_CUDA - std::enable_if_t::value> + requires IsCallable::value #else - std::enable_if_t::value> + requires IsCallableR::value #endif - fill_local_id (Marker const& marker); + void fill_local_id (Marker const& marker); //! Convert the local ids to globally unique ids visible to HYPRE. template @@ -124,11 +124,11 @@ public: * `HYPRE_Int& ncols, HYPRE_Int* cols, HYPRE_Real* mat)` that emits the nonzeros * for each DOF. */ - template const*, - HYPRE_Int&, HYPRE_Int*, - HYPRE_Real*>::value,int> FOO = 0> + template + requires IsCallable const*, + HYPRE_Int&, HYPRE_Int*, + HYPRE_Real*>::value void fill_matrix (Filler const& filler); /** @@ -137,9 +137,9 @@ public: * \param a_soln Solution MultiFabs (initial guess overwritten). * \param a_rhs RHS MultiFabs. */ - template ::value && - std::is_same_v, int> = 0> + template + requires IsFabArray::value && + std::is_same_v void load_vectors (Vector const& a_soln, Vector const& a_rhs); @@ -148,9 +148,9 @@ public: * * \param a_soln Solution MultiFabs populated in place. */ - template ::value && - std::is_same_v, int> = 0> + template + requires IsFabArray::value && + std::is_same_v void get_solution (Vector const& a_soln); private: @@ -305,10 +305,11 @@ HypreSolver::HypreSolver (Vector const& a_index_type, template template #ifdef AMREX_USE_CUDA - std::enable_if_t::value> +requires IsCallable::value #else - std::enable_if_t::value> +requires IsCallableR::value #endif +void HypreSolver::fill_local_id (Marker const& marker) { BL_PROFILE("HypreSolver::fill_local_id()"); @@ -502,11 +503,11 @@ void pack_matrix_gpu (Gpu::DeviceVector& cols_tmp, #endif template -template const*, - HYPRE_Int&, HYPRE_Int*, - HYPRE_Real*>::value,int> FOO> +template +requires IsCallable const*, + HYPRE_Int&, HYPRE_Int*, + HYPRE_Real*>::value void HypreSolver::fill_matrix (Filler const& filler) { @@ -605,9 +606,9 @@ HypreSolver::fill_matrix (Filler const& filler) } template -template ::value && - std::is_same_v, int> FOO> +template +requires IsFabArray::value && + std::is_same_v void HypreSolver::solve (Vector const& a_soln, Vector const& a_rhs, @@ -631,9 +632,9 @@ HypreSolver::solve (Vector const& a_soln, } template -template ::value && - std::is_same_v, int> FOO> +template +requires IsFabArray::value && + std::is_same_v void HypreSolver::load_vectors (Vector const& a_soln, Vector const& a_rhs) @@ -688,9 +689,9 @@ HypreSolver::load_vectors (Vector const& a_soln, } template -template ::value && - std::is_same_v, int> FOO> +template +requires IsFabArray::value && + std::is_same_v void HypreSolver::get_solution (Vector const& a_soln) { diff --git a/Src/FFT/AMReX_FFT_LocalR2C.H b/Src/FFT/AMReX_FFT_LocalR2C.H index e1fc92a95ae..efcce87c93b 100644 --- a/Src/FFT/AMReX_FFT_LocalR2C.H +++ b/Src/FFT/AMReX_FFT_LocalR2C.H @@ -92,8 +92,8 @@ public: * \param indata input data * \param outdata output data */ - template = 0> + template + requires (DIR == Direction::forward) || (DIR == Direction::both) void forward (T const* indata, GpuComplex* outdata); /** @@ -111,8 +111,8 @@ public: * \param indata input data * \param outdata output data */ - template = 0> + template + requires (DIR == Direction::backward) || (DIR == Direction::both) void backward (GpuComplex const* indata, T* outdata); /** @@ -260,8 +260,8 @@ LocalR2C& LocalR2C::operator= (LocalR2C && rhs) noexcept } template -template > +template +requires (DIR == Direction::forward) || (DIR == Direction::both) void LocalR2C::forward (T const* indata, GpuComplex* outdata) { BL_PROFILE("FFT::LocalR2C::forward"); @@ -305,8 +305,8 @@ void LocalR2C::forward (T const* indata, GpuComplex* outdata) } template -template > +template +requires (DIR == Direction::backward) || (DIR == Direction::both) void LocalR2C::backward (GpuComplex const* indata, T* outdata) { BL_PROFILE("FFT::LocalR2C::backward"); diff --git a/Src/FFT/AMReX_FFT_Poisson.H b/Src/FFT/AMReX_FFT_Poisson.H index d822786c882..39cccafefd3 100644 --- a/Src/FFT/AMReX_FFT_Poisson.H +++ b/Src/FFT/AMReX_FFT_Poisson.H @@ -73,7 +73,8 @@ public: * \param geom Geometry describing the domain and metric information. * \param bc Pair of boundary descriptors (low/high) per coordinate direction. */ - template ,int> = 0> + template + requires IsFabArray_v Poisson (Geometry const& geom, Array,AMREX_SPACEDIM> const& bc) : m_domain_lo(geom.Domain().smallEnd()), @@ -98,7 +99,8 @@ public: * * \param geom Periodic geometry (all directions must be periodic). */ - template ,int> = 0> + template + requires IsFabArray_v explicit Poisson (Geometry const& geom) : m_domain_lo(geom.Domain().smallEnd()), m_geom(detail::shift_geom(geom)), @@ -150,7 +152,8 @@ public: * \param ixtype Index type (cell vs. node) for the working arrays. * \param ngrow Number of grow cells applied prior to solving. */ - template ,int> = 0> + template + requires IsFabArray_v explicit PoissonOpenBC (Geometry const& geom, IndexType ixtype = IndexType::TheCellType(), IntVect const& ngrow = IntVect(0)); @@ -194,7 +197,8 @@ public: * \param geom Geometry describing domain and spacing. * \param bc Boundary descriptors for each direction. */ - template ,int> = 0> + template + requires IsFabArray_v PoissonHybrid (Geometry const& geom, Array,AMREX_SPACEDIM> const& bc) : m_domain_lo(geom.Domain().smallEnd()), @@ -394,7 +398,8 @@ void Poisson::solve (MF& a_soln, MF const& a_rhs) #if (AMREX_SPACEDIM == 3) template -template ,int> FOO> +template +requires IsFabArray_v PoissonOpenBC::PoissonOpenBC (Geometry const& geom, IndexType ixtype, IntVect const& ngrow) : m_geom(geom), diff --git a/Src/FFT/AMReX_FFT_R2C.H b/Src/FFT/AMReX_FFT_R2C.H index c1f3d1521ed..9b818ed91ee 100644 --- a/Src/FFT/AMReX_FFT_R2C.H +++ b/Src/FFT/AMReX_FFT_R2C.H @@ -197,8 +197,8 @@ public: * \param incomp component index of input data * \param outcomp component index of output data */ - template = 0> + template + requires (DIR == Direction::both) void forwardThenBackward (MF const& inmf, MF& outmf, F const& post_forward, int incomp = 0, int outcomp = 0) { @@ -221,8 +221,8 @@ public: * \param inmf input data in MultiFab or FabArray> * \param incomp component index of input data */ - template = 0> + template + requires (DIR == Direction::forward) || (DIR == Direction::both) void forward (MF const& inmf, int incomp = 0); /** @@ -236,8 +236,8 @@ public: * \param incomp component index of input data * \param outcomp component index of output data */ - template = 0> + template + requires (DIR == Direction::forward) || (DIR == Direction::both) void forward (MF const& inmf, cMF& outmf, int incomp = 0, int outcomp = 0); /** @@ -256,11 +256,10 @@ public: * \param in Real-domain input data laid out as specified by setLocalDomain. * \param out Complex-domain buffer that receives the Hermitian half-spectrum. */ - template = 0> + template + requires ((DIR == Direction::forward) || (DIR == Direction::both)) && + (((sizeof(RT)*2 == sizeof(CT)) && (!CP)) || + ((sizeof(RT) == sizeof(CT)) && CP)) void forward (RT const* in, CT* out); /** @@ -272,7 +271,8 @@ public: * \param outmf output data in MultiFab or FabArray> * \param outcomp component index of output data */ - template = 0> + template + requires (DIR == Direction::both) void backward (MF& outmf, int outcomp = 0); /** @@ -286,8 +286,8 @@ public: * \param incomp component index of input data * \param outcomp component index of output data */ - template = 0> + template + requires (DIR == Direction::backward) || (DIR == Direction::both) void backward (cMF const& inmf, MF& outmf, int incomp = 0, int outcomp = 0); /** @@ -306,11 +306,10 @@ public: * \param in Complex-domain data. * \param out Real-domain buffer that receives the transformed data. */ - template = 0> + template + requires ((DIR == Direction::backward) || (DIR == Direction::both)) && + (((sizeof(RT)*2 == sizeof(CT)) && (!CP)) || + ((sizeof(RT) == sizeof(CT)) && CP)) void backward (CT const* in, RT* out); /** @@ -333,8 +332,8 @@ public: * * \return Pair of (spectral MultiFab pointer, permutation describing storage order). */ - template = 0> + template + requires (DIR == Direction::forward) || (DIR == Direction::both) std::pair getSpectralData () const; /** @@ -894,8 +893,8 @@ void R2C::prepare_openbc () } template -template > +template +requires (DIR == Direction::forward) || (DIR == Direction::both) void R2C::forward (MF const& inmf, int incomp) { BL_PROFILE("FFT::R2C::forward(in)"); @@ -1004,11 +1003,10 @@ R2C::install_raw_ptr (FA& fa, RT const* p) template -template > +template +requires ((DIR == Direction::forward) || (DIR == Direction::both)) && + (((sizeof(RT)*2 == sizeof(CT)) && (!CP)) || + ((sizeof(RT) == sizeof(CT)) && CP)) void R2C::forward (RT const* in, CT* out) { auto [rdata, rsz] = install_raw_ptr(m_raw_mf, in); @@ -1028,7 +1026,8 @@ void R2C::forward (RT const* in, CT* out) } template -template > +template +requires (DIR == Direction::both) void R2C::backward (MF& outmf, int outcomp) { backward_doit(outmf, IntVect(0), Periodicity::NonPeriodic(), outcomp); @@ -1095,11 +1094,10 @@ void R2C::backward_doit (MF& outmf, IntVect const& ngout, } template -template > +template +requires ((DIR == Direction::backward) || (DIR == Direction::both)) && + (((sizeof(RT)*2 == sizeof(CT)) && (!CP)) || + ((sizeof(RT) == sizeof(CT)) && CP)) void R2C::backward (CT const* in, RT* out) { auto [rdata, rsz] = install_raw_ptr(m_raw_mf, out); @@ -1267,8 +1265,8 @@ T R2C::scalingFactor () const } template -template > +template +requires (DIR == Direction::forward) || (DIR == Direction::both) std::pair::cMF *, IntVect> R2C::getSpectralData () const { @@ -1288,8 +1286,8 @@ R2C::getSpectralData () const } template -template > +template +requires (DIR == Direction::forward) || (DIR == Direction::both) void R2C::forward (MF const& inmf, cMF& outmf, int incomp, int outcomp) { BL_PROFILE("FFT::R2C::forward(inout)"); @@ -1348,8 +1346,8 @@ void R2C::forward (MF const& inmf, cMF& outmf, int incomp, int outcomp) } template -template > +template +requires (DIR == Direction::backward) || (DIR == Direction::both) void R2C::backward (cMF const& inmf, MF& outmf, int incomp, int outcomp) { backward_doit(inmf, outmf, IntVect(0), Periodicity::NonPeriodic(), incomp, outcomp); diff --git a/Src/LinearSolvers/AMReX_AlgVecUtil.H b/Src/LinearSolvers/AMReX_AlgVecUtil.H index 4dd079a4caa..d967b43e0c6 100644 --- a/Src/LinearSolvers/AMReX_AlgVecUtil.H +++ b/Src/LinearSolvers/AMReX_AlgVecUtil.H @@ -29,7 +29,8 @@ struct IsAlgVector -std::enable_if_t >::value> +requires IsAlgVector >::value +void ForEach (V1 & x, F const& f) { Long n = x.numLocalRows(); @@ -48,8 +49,9 @@ ForEach (V1 & x, F const& f) * \param f Callable with signature `void(X&, Y&)`. */ template -std::enable_if_t >::value && - IsAlgVector >::value> +requires IsAlgVector >::value && + IsAlgVector >::value +void ForEach (V1 & x, V2 & y, F const& f) { AMREX_ASSERT(x.numLocalRows() == y.numLocalRows()); @@ -71,9 +73,10 @@ ForEach (V1 & x, V2 & y, F const& f) * \param f Callable with signature `void(X&, Y&, Z&)`. */ template -std::enable_if_t >::value && - IsAlgVector >::value && - IsAlgVector >::value> +requires IsAlgVector >::value && + IsAlgVector >::value && + IsAlgVector >::value +void ForEach (V1 & x, V2 & y, V3 & z, F const& f) { AMREX_ASSERT(x.numLocalRows() == y.numLocalRows()); @@ -98,10 +101,11 @@ ForEach (V1 & x, V2 & y, V3 & z, F const& f) * \param f Callable with signature `void(X&, Y&, Z&, A&)`. */ template -std::enable_if_t >::value && - IsAlgVector >::value && - IsAlgVector >::value && - IsAlgVector >::value> +requires IsAlgVector >::value && + IsAlgVector >::value && + IsAlgVector >::value && + IsAlgVector >::value +void ForEach (V1 & x, V2 & y, V3 & z, V4 & a, F const& f) { AMREX_ASSERT(x.numLocalRows() == y.numLocalRows()); @@ -129,11 +133,12 @@ ForEach (V1 & x, V2 & y, V3 & z, V4 & a, F const& f) * \param f Callable with signature `void(X&, Y&, Z&, A&, B&)`. */ template -std::enable_if_t >::value && - IsAlgVector >::value && - IsAlgVector >::value && - IsAlgVector >::value && - IsAlgVector >::value> +requires IsAlgVector >::value && + IsAlgVector >::value && + IsAlgVector >::value && + IsAlgVector >::value && + IsAlgVector >::value +void ForEach (V1 & x, V2 & y, V3 & z, V4 & a, V5 & b, F const& f) { AMREX_ASSERT(x.numLocalRows() == y.numLocalRows()); diff --git a/Src/LinearSolvers/AMReX_CSR.H b/Src/LinearSolvers/AMReX_CSR.H index 1619b12d255..5bf6a272ef3 100644 --- a/Src/LinearSolvers/AMReX_CSR.H +++ b/Src/LinearSolvers/AMReX_CSR.H @@ -102,10 +102,10 @@ struct CSR { void sort_on_host (); }; -template class AD, template class AS, - std::enable_if_t || - std::is_same_v || - std::is_same_v, int> = 0> +template class AD, template class AS> +requires (std::is_same_v) || + (std::is_same_v) || + (std::is_same_v) /** * \brief Copy CSR buffers between memory spaces asynchronously. * diff --git a/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.H b/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.H index 4363deba4f9..a064a9b637f 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLABecLaplacian.H @@ -64,10 +64,9 @@ public: * `(A \alpha - B \nabla \cdot \beta \nabla ) \phi = f` * for the Multi-Level AB Laplacian Solver. */ - template && - std::is_convertible_v, - int> = 0> + template + requires std::is_convertible_v && + std::is_convertible_v void setScalars (T1 a, T2 b) noexcept; /** @@ -79,11 +78,9 @@ public: * AMR hierarchy represented in the solve. * \param [in] alpha Multifab of alpha values. */ - template ::value && - std::is_convertible_v, - int> = 0> + template + requires IsFabArray::value && + std::is_convertible_v void setACoeffs (int amrlev, const AMF& alpha); /** @@ -95,9 +92,8 @@ public: * AMR hierarchy represented in the solve. * \param [in] alpha Single scalar value to populate across multifab. */ - template , - int> = 0> + template + requires std::is_convertible_v void setACoeffs (int amrlev, T alpha); /** @@ -109,11 +105,9 @@ public: * AMR hierarchy represented in the solve. * \param [in] beta Array of Multifabs of beta values. */ - template ::value && - std::is_convertible_v, - int> = 0> + template + requires IsFabArray::value && + std::is_convertible_v void setBCoeffs (int amrlev, const Array& beta); /** @@ -125,9 +119,8 @@ public: * AMR hierarchy represented in the solve. * \param [in] beta Single scalar value to populate across multifabs. */ - template , - int> = 0> + template + requires std::is_convertible_v void setBCoeffs (int amrlev, T beta); /** @@ -139,9 +132,8 @@ public: * AMR hierarchy represented in the solve. * \param [in] beta Vector of scalar constant values. */ - template , - int> = 0> + template + requires std::is_convertible_v void setBCoeffs (int amrlev, Vector const& beta); [[nodiscard]] int getNComp () const override { return m_ncomp; } @@ -299,9 +291,9 @@ MLABecLaplacianT::define_ab_coeffs () } template -template && - std::is_convertible_v, int>> +template +requires std::is_convertible_v && + std::is_convertible_v void MLABecLaplacianT::setScalars (T1 a, T2 b) noexcept { @@ -317,10 +309,9 @@ MLABecLaplacianT::setScalars (T1 a, T2 b) noexcept } template -template ::value && - std::is_convertible_v, int>> +template +requires IsFabArray::value && + std::is_convertible_v void MLABecLaplacianT::setACoeffs (int amrlev, const AMF& alpha) { @@ -332,8 +323,8 @@ MLABecLaplacianT::setACoeffs (int amrlev, const AMF& alpha) } template -template ,int>> +template +requires std::is_convertible_v void MLABecLaplacianT::setACoeffs (int amrlev, T alpha) { @@ -344,10 +335,9 @@ MLABecLaplacianT::setACoeffs (int amrlev, T alpha) template -template ::value && - std::is_convertible_v, int>> +template +requires IsFabArray::value && + std::is_convertible_v void MLABecLaplacianT::setBCoeffs (int amrlev, const Array& beta) @@ -371,8 +361,8 @@ MLABecLaplacianT::setBCoeffs (int amrlev, } template -template ,int>> +template +requires std::is_convertible_v void MLABecLaplacianT::setBCoeffs (int amrlev, T beta) { @@ -383,8 +373,8 @@ MLABecLaplacianT::setBCoeffs (int amrlev, T beta) } template -template ,int>> +template +requires std::is_convertible_v void MLABecLaplacianT::setBCoeffs (int amrlev, Vector const& beta) { diff --git a/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H b/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H index 0f77a4bcd8f..be38ce13d09 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLCellLinOp.H @@ -51,8 +51,8 @@ public: const MF* robinbc_b = nullptr, const MF* robinbc_f = nullptr) final; - template && - IsMultiFabLike_v, int> = 0> + template + requires (!std::is_same_v) && (IsMultiFabLike_v) void setLevelBC (int amrlev, const AMF* levelbcdata, const AMF* robinbc_a = nullptr, const AMF* robinbc_b = nullptr, diff --git a/Src/LinearSolvers/MLMG/AMReX_MLLinOp.H b/Src/LinearSolvers/MLMG/AMReX_MLLinOp.H index e51c05cefba..5d907b6966c 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLLinOp.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLLinOp.H @@ -207,11 +207,13 @@ public: void setCoarseFineBC (const MF* crse, IntVect const& crse_ratio, LinOpBCType bc_type = LinOpBCType::Dirichlet) noexcept; - template ,int> = 0> + template + requires (!std::is_same_v) void setCoarseFineBC (const AMF* crse, int crse_ratio, LinOpBCType bc_type = LinOpBCType::Dirichlet) noexcept; - template ,int> = 0> + template + requires (!std::is_same_v) void setCoarseFineBC (const AMF* crse, IntVect const& crse_ratio, LinOpBCType bc_type = LinOpBCType::Dirichlet) noexcept; @@ -238,8 +240,8 @@ public: const MF* /*robinbc_b*/ = nullptr, const MF* /*robinbc_f*/ = nullptr) = 0; - template && - IsMultiFabLike_v, int> = 0> + template + requires (!std::is_same_v) && (IsMultiFabLike_v) void setLevelBC (int amrlev, const AMF* levelbcdata, const AMF* robinbc_a = nullptr, const AMF* robinbc_b = nullptr, @@ -1469,7 +1471,8 @@ MLLinOpT::setCoarseFineBC (const MF* crse, IntVect const& crse_ratio, } template -template ,int>> +template +requires (!std::is_same_v) void MLLinOpT::setCoarseFineBC (const AMF* crse, int crse_ratio, LinOpBCType bc_type) noexcept @@ -1478,7 +1481,8 @@ MLLinOpT::setCoarseFineBC (const AMF* crse, int crse_ratio, } template -template ,int>> +template +requires (!std::is_same_v) void MLLinOpT::setCoarseFineBC (const AMF* crse, IntVect const& crse_ratio, LinOpBCType bc_type) noexcept @@ -1620,8 +1624,8 @@ MLLinOpT::isMFIterSafe (int amrlev, int mglev1, int mglev2) const } template -template && - IsMultiFabLike_v, int> > +template +requires (!std::is_same_v) && (IsMultiFabLike_v) void MLLinOpT::setLevelBC (int amrlev, const AMF* levelbcdata, const AMF* robinbc_a, const AMF* robinbc_b, diff --git a/Src/LinearSolvers/MLMG/AMReX_MLMG.H b/Src/LinearSolvers/MLMG/AMReX_MLMG.H index e35f4f47e71..e7eb069eeb0 100644 --- a/Src/LinearSolvers/MLMG/AMReX_MLMG.H +++ b/Src/LinearSolvers/MLMG/AMReX_MLMG.H @@ -228,12 +228,14 @@ public: void makeSolvable (int amrlev, int mglev, MF& mf); #if defined(AMREX_USE_HYPRE) && (AMREX_SPACEDIM > 1) - template ,int> = 0> + template + requires std::is_same_v void bottomSolveWithHypre (MF& x, const MF& b); #endif #if defined(AMREX_USE_PETSC) && (AMREX_SPACEDIM > 1) - template ,int> = 0> + template + requires std::is_same_v void bottomSolveWithPETSc (MF& x, const MF& b); #endif @@ -1919,7 +1921,8 @@ MLMGT::makeSolvable (int amrlev, int mglev, MF& mf) #if defined(AMREX_USE_HYPRE) && (AMREX_SPACEDIM > 1) template -template ,int>> +template +requires std::is_same_v void MLMGT::bottomSolveWithHypre (MF& x, const MF& b) { @@ -1989,7 +1992,8 @@ MLMGT::bottomSolveWithHypre (MF& x, const MF& b) #if defined(AMREX_USE_PETSC) && (AMREX_SPACEDIM > 1) template -template ,int>> +template +requires std::is_same_v void MLMGT::bottomSolveWithPETSc (MF& x, const MF& b) { diff --git a/Src/Particle/AMReX_ParticleCommunication.H b/Src/Particle/AMReX_ParticleCommunication.H index 58496e389e6..a3fecd1dd39 100644 --- a/Src/Particle/AMReX_ParticleCommunication.H +++ b/Src/Particle/AMReX_ParticleCommunication.H @@ -403,7 +403,8 @@ public: Long superParticleSize() const { return m_superparticle_size; } - template ::value, int> foo = 0> + template +requires IsParticleContainer::value void build (const PC& pc, const ParticleCopyOp& op, const Vector& int_comp_mask, @@ -574,10 +575,9 @@ struct GetSendBufferOffset } }; -template ::value && - std::is_base_of_v, - Buffer>, int> foo = 0> +template +requires IsParticleContainer::value && + std::is_base_of_v, Buffer> void packBuffer (const PC& pc, const ParticleCopyOp& op, const ParticleCopyPlan& plan, Buffer& snd_buffer) { @@ -776,8 +776,8 @@ void packBuffer (const PC& pc, const ParticleCopyOp& op, const ParticleCopyPlan& #endif } -template ::value, int> foo = 0> +template +requires IsParticleContainer::value void unpackBuffer (PC& pc, const ParticleCopyPlan& plan, const Buffer& snd_buffer, UnpackPolicy const& policy) { BL_PROFILE("amrex::unpackBuffer"); @@ -903,8 +903,8 @@ void unpackBuffer (PC& pc, const ParticleCopyPlan& plan, const Buffer& snd_buffe #endif } -template ::value, int> foo = 0> +template +requires IsParticleContainer::value void communicateParticlesStart (const PC& pc, ParticleCopyPlan& plan, const SndBuffer& snd_buffer, RcvBuffer& rcv_buffer) { BL_PROFILE("amrex::communicateParticlesStart"); @@ -1003,8 +1003,8 @@ void communicateParticlesStart (const PC& pc, ParticleCopyPlan& plan, const SndB void communicateParticlesFinish (const ParticleCopyPlan& plan); -template ::value, int> foo = 0> +template +requires IsParticleContainer::value void unpackRemotes (PC& pc, const ParticleCopyPlan& plan, Buffer& rcv_buffer, UnpackPolicy const& policy) { BL_PROFILE("amrex::unpackRemotes"); diff --git a/Src/Particle/AMReX_ParticleContainer.H b/Src/Particle/AMReX_ParticleContainer.H index bb9cc487090..4669ee5b4b1 100644 --- a/Src/Particle/AMReX_ParticleContainer.H +++ b/Src/Particle/AMReX_ParticleContainer.H @@ -592,7 +592,8 @@ public: /** * \brief Return capacity of memory for particles at specific grid */ - template && (sizeof(I) >= sizeof(Long)), int> = 0> + template + requires std::is_integral_v && (sizeof(I) >= sizeof(Long)) void CapacityOfParticlesInGrid (LayoutData& mem, int lev) const; /** @@ -688,8 +689,8 @@ public: * \param other the other pc to copy from * \param local whether to call redistribute after */ - template ::value, int> foo = 0> + template + requires IsParticleContainer::value void copyParticles (const PCType& other, bool local=false); /** @@ -699,8 +700,8 @@ public: * \param other the other pc to copy from * \param local whether to call redistribute after */ - template ::value, int> foo = 0> + template + requires IsParticleContainer::value void addParticles (const PCType& other, bool local=false); /** @@ -717,9 +718,8 @@ public: * \param f function to apply to each particle as a filter * \param local whether to call redistribute after */ - template ::value, int> foo = 0, - std::enable_if_t, int> bar = 0> + template + requires (IsParticleContainer::value) && (!std::is_integral_v) void copyParticles (const PCType& other, F&&f, bool local=false); /** @@ -735,9 +735,8 @@ public: * \param f function to apply to each particle as a filter * \param local whether to call redistribute after */ - template ::value, int> foo = 0, - std::enable_if_t, int> bar = 0> + template + requires (IsParticleContainer::value) && (!std::is_integral_v) void addParticles (const PCType& other, F const& f, bool local=false); /** diff --git a/Src/Particle/AMReX_ParticleContainerI.H b/Src/Particle/AMReX_ParticleContainerI.H index e0eb6c8496c..badd4f8fac2 100644 --- a/Src/Particle/AMReX_ParticleContainerI.H +++ b/Src/Particle/AMReX_ParticleContainerI.H @@ -588,7 +588,8 @@ Long ParticleContainer_impl class Allocator, class CellAssignor> -template && (sizeof(I) >= sizeof(Long)), int> FOO> +template +requires std::is_integral_v && (sizeof(I) >= sizeof(Long)) void ParticleContainer_impl::CapacityOfParticlesInGrid (LayoutData& mem, int lev) const { @@ -1138,7 +1139,8 @@ clearParticles () template class Allocator, class CellAssignor> -template ::value, int> foo> +template +requires IsParticleContainer::value void ParticleContainer_impl:: copyParticles (const PCType& other, bool local) @@ -1149,7 +1151,8 @@ copyParticles (const PCType& other, bool local) template class Allocator, class CellAssignor> -template ::value, int> foo> +template +requires IsParticleContainer::value void ParticleContainer_impl:: addParticles (const PCType& other, bool local) @@ -1160,9 +1163,8 @@ addParticles (const PCType& other, bool local) template class Allocator, class CellAssignor> -template ::value, int> foo, - std::enable_if_t, int> bar> +template +requires (IsParticleContainer::value) && (!std::is_integral_v) void ParticleContainer_impl:: copyParticles (const PCType& other, F&& f, bool local) @@ -1174,9 +1176,8 @@ copyParticles (const PCType& other, F&& f, bool local) template class Allocator, class CellAssignor> -template ::value, int> foo, - std::enable_if_t, int> bar> +template +requires (IsParticleContainer::value) && (!std::is_integral_v) void ParticleContainer_impl:: addParticles (const PCType& other, F const& f, bool local) diff --git a/Src/Particle/AMReX_ParticleMesh.H b/Src/Particle/AMReX_ParticleMesh.H index 9ac149a3066..c7e86b37391 100644 --- a/Src/Particle/AMReX_ParticleMesh.H +++ b/Src/Particle/AMReX_ParticleMesh.H @@ -55,7 +55,8 @@ auto call_f (F const& f, } /// \endcond -template ::value, int> foo = 0> +template +requires IsParticleContainer::value void ParticleToMesh (PC const& pc, MF& mf, int lev, F const& f, bool zero_out_input=true) { @@ -140,7 +141,8 @@ ParticleToMesh (PC const& pc, MF& mf, int lev, F const& f, bool zero_out_input=t } } -template ::value, int> foo = 0> +template +requires IsParticleContainer::value void MeshToParticle (PC& pc, MF const& mf, int lev, F const& f) { diff --git a/Src/Particle/AMReX_ParticleReduce.H b/Src/Particle/AMReX_ParticleReduce.H index c8bacdf0b55..863268df630 100644 --- a/Src/Particle/AMReX_ParticleReduce.H +++ b/Src/Particle/AMReX_ParticleReduce.H @@ -86,7 +86,8 @@ auto call_f (F const& f, * \endcode * */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value auto ReduceSum (PC const& pc, F&& f) -> decltype(particle_detail::call_f(f, typename PC::ConstPTDType(), int())) @@ -134,7 +135,8 @@ ReduceSum (PC const& pc, F&& f) * }); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value auto ReduceSum (PC const& pc, int lev, F&& f) -> decltype(particle_detail::call_f(f, typename PC::ConstPTDType(), int())) @@ -183,7 +185,8 @@ ReduceSum (PC const& pc, int lev, F&& f) * }); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value auto ReduceSum (PC const& pc, int lev_min, int lev_max, F const& f) -> decltype(particle_detail::call_f(f, typename PC::ConstPTDType(), int())) @@ -288,7 +291,8 @@ ReduceSum (PC const& pc, int lev_min, int lev_max, F const& f) * }); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value auto ReduceMax (PC const& pc, F&& f) -> decltype(particle_detail::call_f(f, typename PC::ConstPTDType(), int())) @@ -337,7 +341,8 @@ ReduceMax (PC const& pc, F&& f) * \endcode * */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value auto ReduceMax (PC const& pc, int lev, F&& f) -> decltype(particle_detail::call_f(f, typename PC::ConstPTDType(), int())) @@ -386,7 +391,8 @@ ReduceMax (PC const& pc, int lev, F&& f) * }); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value auto ReduceMax (PC const& pc, int lev_min, int lev_max, F const& f) -> decltype(particle_detail::call_f(f, typename PC::ConstPTDType(), int())) @@ -492,7 +498,8 @@ ReduceMax (PC const& pc, int lev_min, int lev_max, F const& f) * }); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value auto ReduceMin (PC const& pc, F&& f) -> decltype(particle_detail::call_f(f, typename PC::ConstPTDType(), int())) @@ -540,7 +547,8 @@ ReduceMin (PC const& pc, F&& f) * }); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value auto ReduceMin (PC const& pc, int lev, F&& f) -> decltype(particle_detail::call_f(f, typename PC::ConstPTDType(), int())) @@ -589,7 +597,8 @@ ReduceMin (PC const& pc, int lev, F&& f) * }); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value auto ReduceMin (PC const& pc, int lev_min, int lev_max, F const& f) -> decltype(particle_detail::call_f(f, typename PC::ConstPTDType(), int())) @@ -695,7 +704,8 @@ ReduceMin (PC const& pc, int lev_min, int lev_max, F const& f) * }); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value bool ReduceLogicalAnd (PC const& pc, F&& f) { @@ -742,7 +752,8 @@ ReduceLogicalAnd (PC const& pc, F&& f) * }); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value bool ReduceLogicalAnd (PC const& pc, int lev, F&& f) { @@ -790,7 +801,8 @@ ReduceLogicalAnd (PC const& pc, int lev, F&& f) * }); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value bool ReduceLogicalAnd (PC const& pc, int lev_min, int lev_max, F const& f) { @@ -893,7 +905,8 @@ ReduceLogicalAnd (PC const& pc, int lev_min, int lev_max, F const& f) * }); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value bool ReduceLogicalOr (PC const& pc, F&& f) { @@ -940,7 +953,8 @@ ReduceLogicalOr (PC const& pc, F&& f) * }); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value bool ReduceLogicalOr (PC const& pc, int lev, F&& f) { @@ -988,7 +1002,8 @@ ReduceLogicalOr (PC const& pc, int lev, F&& f) * }); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value bool ReduceLogicalOr (PC const& pc, int lev_min, int lev_max, F const& f) { @@ -1115,8 +1130,8 @@ ReduceLogicalOr (PC const& pc, int lev_min, int lev_max, F const& f) * }, reduce_ops); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value typename RD::Type ParticleReduce (PC const& pc, F&& f, ReduceOps& reduce_ops) { @@ -1186,8 +1201,8 @@ ParticleReduce (PC const& pc, F&& f, ReduceOps& reduce_ops) * }, reduce_ops); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value typename RD::Type ParticleReduce (PC const& pc, int lev, F&& f, ReduceOps& reduce_ops) { @@ -1258,8 +1273,8 @@ ParticleReduce (PC const& pc, int lev, F&& f, ReduceOps& reduce_ops) * }, reduce_ops); * \endcode */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value typename RD::Type ParticleReduce (PC const& pc, int lev_min, int lev_max, F const& f, ReduceOps& reduce_ops) { diff --git a/Src/Particle/AMReX_ParticleTransformation.H b/Src/Particle/AMReX_ParticleTransformation.H index 6488d8bb94a..9a4ee7b3a11 100644 --- a/Src/Particle/AMReX_ParticleTransformation.H +++ b/Src/Particle/AMReX_ParticleTransformation.H @@ -241,8 +241,8 @@ void copyParticles (DstTile& dst, const SrcTile& src) noexcept * \param n the number of particles to write * */ -template , int> foo = 0> +template +requires std::is_integral_v void copyParticles (DstTile& dst, const SrcTile& src, Index src_start, Index dst_start, N n) noexcept { @@ -297,8 +297,8 @@ void transformParticles (DstTile& dst, const SrcTile& src, F&& f) noexcept * \param f the function that will be applied to each particle * */ -template , int> foo = 0> +template +requires std::is_integral_v void transformParticles (DstTile& dst, const SrcTile& src, Index src_start, Index dst_start, N n, F const& f) noexcept { @@ -359,8 +359,8 @@ void transformParticles (DstTile1& dst1, DstTile2& dst2, const SrcTile& src, F&& * */ template , int> foo = 0> + typename Index, typename N, typename F> +requires std::is_integral_v void transformParticles (DstTile1& dst1, DstTile2& dst2, const SrcTile& src, Index src_start, Index dst1_start, Index dst2_start, N n, F const& f) noexcept { @@ -388,8 +388,8 @@ void transformParticles (DstTile1& dst1, DstTile2& dst2, const SrcTile& src, * \param mask pointer to the mask - 1 means copy, 0 means don't copy * */ -template , int> foo = 0> +template +requires std::is_integral_v Index filterParticles (DstTile& dst, const SrcTile& src, const Index* mask) noexcept { return filterParticles(dst, src, mask, Index{0}, Index{0}, src.numParticles()); @@ -412,8 +412,8 @@ Index filterParticles (DstTile& dst, const SrcTile& src, const Index* mask) noex * \param n the number of particles to apply the operation to * */ -template , int> foo = 0> +template +requires std::is_integral_v Index filterParticles (DstTile& dst, const SrcTile& src, const Index* mask, Index src_start, Index dst_start, N n) noexcept { @@ -450,8 +450,8 @@ Index filterParticles (DstTile& dst, const SrcTile& src, const Index* mask, * \param p predicate function - particles will be copied if p returns true * */ -template >,int> foo = 0> +template +requires (!std::is_pointer_v>) int filterParticles (DstTile& dst, const SrcTile& src, Pred&& p) noexcept { return filterParticles(dst, src, std::forward(p), 0, 0, src.numParticles()); @@ -474,8 +474,8 @@ int filterParticles (DstTile& dst, const SrcTile& src, Pred&& p) noexcept * \param n the number of particles to apply the operation to * */ -template >,Index> nvccfoo = 0> +template +requires (!std::is_pointer_v>) Index filterParticles (DstTile& dst, const SrcTile& src, Pred const& p, Index src_start, Index dst_start, N n) noexcept { @@ -514,8 +514,8 @@ Index filterParticles (DstTile& dst, const SrcTile& src, Pred const& p, * \param f defines the transformation that will be applied to the particles on copy * */ -template , int> foo = 0> +template +requires std::is_integral_v Index filterAndTransformParticles (DstTile& dst, const SrcTile& src, Index* mask, F const& f, Index src_start, Index dst_start) noexcept { @@ -559,8 +559,8 @@ Index filterAndTransformParticles (DstTile& dst, const SrcTile& src, Index* mask * \param f defines the transformation that will be applied to the particles on copy * */ -template , int> foo = 0> +template +requires std::is_integral_v Index filterAndTransformParticles (DstTile& dst, const SrcTile& src, Index* mask, F&& f) noexcept { return filterAndTransformParticles(dst, src, mask, std::forward(f), Index{0}, Index{0}); @@ -581,8 +581,8 @@ Index filterAndTransformParticles (DstTile& dst, const SrcTile& src, Index* mask * \param f defines the transformation that will be applied to the particles on copy * */ -template >,int> foo = 0> +template +requires (!std::is_pointer_v>) int filterAndTransformParticles (DstTile& dst, const SrcTile& src, Pred&& p, F&& f) noexcept { using Index = decltype(src.numParticles()); @@ -607,8 +607,8 @@ int filterAndTransformParticles (DstTile& dst, const SrcTile& src, Pred&& p, F&& * \param f defines the transformation that will be applied to the particles on copy * */ -template , int> foo = 0> +template +requires std::is_integral_v Index filterAndTransformParticles (DstTile1& dst1, DstTile2& dst2, const SrcTile& src, Index* mask, F const& f) noexcept { @@ -652,8 +652,8 @@ Index filterAndTransformParticles (DstTile1& dst1, DstTile2& dst2, * \param f defines the transformation that will be applied to the particles on copy * */ -template >, int> foo = 0> +template +requires (!std::is_pointer_v>) int filterAndTransformParticles (DstTile1& dst1, DstTile2& dst2, const SrcTile& src, Pred const& p, F&& f) noexcept { @@ -694,8 +694,8 @@ int filterAndTransformParticles (DstTile1& dst1, DstTile2& dst2, const SrcTile& * \param dst_start the offset at which to start writing particles to dst * */ -template >,Index> nvccfoo = 0> +template +requires (!std::is_pointer_v>) Index filterAndTransformParticles (DstTile& dst, const SrcTile& src, Pred const& p, F&& f, Index src_start, Index dst_start) noexcept { @@ -734,8 +734,8 @@ Index filterAndTransformParticles (DstTile& dst, const SrcTile& src, Pred const& * \param inds pointer to the permutation array * */ -template , int> foo = 0> +template +requires std::is_integral_v void gatherParticles (PTile& dst, const PTile& src, N np, const Index* inds) { const auto src_data = src.getConstParticleTileData(); @@ -764,8 +764,8 @@ void gatherParticles (PTile& dst, const PTile& src, N np, const Index* inds) * \param inds pointer to the permutation array * */ -template , int> foo = 0> +template +requires std::is_integral_v void scatterParticles (PTile& dst, const PTile& src, N np, const Index* inds) { const auto src_data = src.getConstParticleTileData(); diff --git a/Src/Particle/AMReX_ParticleUtil.H b/Src/Particle/AMReX_ParticleUtil.H index c781dbd3266..045a8abce18 100644 --- a/Src/Particle/AMReX_ParticleUtil.H +++ b/Src/Particle/AMReX_ParticleUtil.H @@ -30,7 +30,8 @@ namespace amrex { * \param nGrow the number of grow cells allowed. * */ -template ::value, int> foo = 0> +template +requires IsParticleIterator::value int numParticlesOutOfRange (Iterator const& pti, int nGrow) { @@ -48,7 +49,8 @@ numParticlesOutOfRange (Iterator const& pti, int nGrow) * \param nGrow the number of grow cells allowed. * */ -template ::value, int> foo = 0> +template +requires IsParticleIterator::value int numParticlesOutOfRange (Iterator const& pti, IntVect nGrow) { @@ -94,7 +96,8 @@ numParticlesOutOfRange (Iterator const& pti, IntVect nGrow) * \param nGrow the number of grow cells allowed. * */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value int numParticlesOutOfRange (PC const& pc, int nGrow) { @@ -113,7 +116,8 @@ numParticlesOutOfRange (PC const& pc, int nGrow) * \param nGrow the number of grow cells allowed. * */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value int numParticlesOutOfRange (PC const& pc, IntVect nGrow) { @@ -134,7 +138,8 @@ numParticlesOutOfRange (PC const& pc, IntVect nGrow) * \param nGrow the number of grow cells allowed. * */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value int numParticlesOutOfRange (PC const& pc, int lev_min, int lev_max, int nGrow) { @@ -158,7 +163,8 @@ numParticlesOutOfRange (PC const& pc, int lev_min, int lev_max, int nGrow) * \param nGrow the number of grow cells allowed. * */ -template ::value, int> foo = 0> +template +requires IsParticleContainer::value int numParticlesOutOfRange (PC const& pc, int lev_min, int lev_max, IntVect nGrow) { @@ -941,8 +947,8 @@ std::string getDefaultCompNameInt (const int i) { * \param ptile * \param permutations */ -template foo = 0> +template +requires (!PTile::ParticleType::is_rtsoa_particle) void ReorderParticles (PTile& ptile, const index_type* permutations) { @@ -1045,8 +1051,8 @@ ReorderParticles (PTile& ptile, const index_type* permutations) * \param ptile * \param permutations */ -template foo = 0> +template +requires PTile::ParticleType::is_rtsoa_particle void ReorderParticles (PTile& ptile, const index_type* permutations) { diff --git a/Src/Particle/AMReX_WriteBinaryParticleData.H b/Src/Particle/AMReX_WriteBinaryParticleData.H index 12f31ab16d9..4f079490223 100644 --- a/Src/Particle/AMReX_WriteBinaryParticleData.H +++ b/Src/Particle/AMReX_WriteBinaryParticleData.H @@ -481,7 +481,8 @@ packIOData (Vector& idata, Vector& rdata, const PC& pc, int l } /// \endcond -template ::value, int> foo = 0> +template +requires IsParticleContainer::value void WriteBinaryParticleDataSync (PC const& pc, const std::string& dir, const std::string& name, const Vector& write_real_comp, @@ -780,7 +781,8 @@ void WriteBinaryParticleDataSync (PC const& pc, } } -template ::value, int> foo = 0> +template +requires IsParticleContainer::value void WriteBinaryParticleDataAsync (PC const& pc, const std::string& dir, const std::string& name, const Vector& write_real_comp,