Skip to content

Commit 4206358

Browse files
authored
No need for AMREX_IS_TRIVIALLY_COPYABLE && AMREX_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE (AMReX-Codes#1921)
They are not needed because gcc 4 is no longer supported.
1 parent 77fb025 commit 4206358

11 files changed

+22
-26
lines changed

Src/Base/AMReX_BaseFab.H

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ placementNew (T* const /*ptr*/, Long /*n*/)
144144
{}
145145

146146
template <typename T>
147-
typename std::enable_if< AMREX_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE(T) && !std::is_arithmetic<T>::value >::type
147+
std::enable_if_t<std::is_trivially_default_constructible<T>::value
148+
&& !std::is_arithmetic<T>::value>
148149
placementNew (T* const ptr, Long n)
149150
{
150151
for (Long i = 0; i < n; ++i) {
@@ -153,7 +154,7 @@ placementNew (T* const ptr, Long n)
153154
}
154155

155156
template <typename T>
156-
typename std::enable_if<!AMREX_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE(T)>::type
157+
std::enable_if_t<!std::is_trivially_default_constructible<T>::value>
157158
placementNew (T* const ptr, Long n)
158159
{
159160
AMREX_HOST_DEVICE_FOR_1D ( n, i,

Src/Base/AMReX_CudaGraph.H

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ struct CudaGraph
6565
CudaGraph()
6666
: m_parms(0)
6767
{
68-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(T), "CudaGraph's T must be trivially copyable");
68+
static_assert(std::is_trivially_copyable<T>::value, "CudaGraph's T must be trivially copyable");
6969
}
7070
CudaGraph(int num)
7171
: m_parms(num)
7272
{
73-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(T), "CudaGraph's T must be trivially copyable");
73+
static_assert(std::is_trivially_copyable<T>::value, "CudaGraph's T must be trivially copyable");
7474
m_parms_d = static_cast<T*>( The_Arena()->alloc(sizeof(T)*m_parms.size()) );
7575
}
7676
~CudaGraph() {

Src/Base/AMReX_GpuAsyncArray.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extern "C" {
2626
namespace amrex {
2727
namespace Gpu {
2828

29-
template <typename T, typename std::enable_if<AMREX_IS_TRIVIALLY_COPYABLE(T),int>::type = 0>
29+
template <typename T, std::enable_if_t<std::is_trivially_copyable<T>::value,int> = 0>
3030
class AsyncArray
3131
{
3232
public:

Src/Base/AMReX_GpuBuffer.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace amrex {
1414
namespace Gpu {
1515

16-
template <typename T, typename std::enable_if<AMREX_IS_TRIVIALLY_COPYABLE(T),int>::type = 0>
16+
template <typename T, std::enable_if_t<std::is_trivially_copyable<T>::value,int> = 0>
1717
class Buffer
1818
{
1919
public:

Src/Base/AMReX_GpuContainers.H

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ namespace Gpu {
115115
void copy (HostToDevice, InIter begin, InIter end, OutIter result) noexcept
116116
{
117117
using value_type = typename std::iterator_traits<InIter>::value_type;
118-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(value_type),
118+
static_assert(std::is_trivially_copyable<value_type>(),
119119
"Can only copy trivially copyable types");
120120
auto size = std::distance(begin, end);
121121
if (size == 0) return;
@@ -148,7 +148,7 @@ namespace Gpu {
148148
void copy (DeviceToHost, InIter begin, InIter end, OutIter result) noexcept
149149
{
150150
using value_type = typename std::iterator_traits<InIter>::value_type;
151-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(value_type),
151+
static_assert(std::is_trivially_copyable<value_type>(),
152152
"Can only copy trivially copyable types");
153153
auto size = std::distance(begin, end);
154154
if (size == 0) return;
@@ -181,7 +181,7 @@ namespace Gpu {
181181
void copy (DeviceToDevice, InIter begin, InIter end, OutIter result) noexcept
182182
{
183183
using value_type = typename std::iterator_traits<InIter>::value_type;
184-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(value_type),
184+
static_assert(std::is_trivially_copyable<value_type>(),
185185
"Can only copy trivially copyable types");
186186
auto size = std::distance(begin, end);
187187
if (size == 0) return;
@@ -215,7 +215,7 @@ namespace Gpu {
215215
void copyAsync (HostToDevice, InIter begin, InIter end, OutIter result) noexcept
216216
{
217217
using value_type = typename std::iterator_traits<InIter>::value_type;
218-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(value_type),
218+
static_assert(std::is_trivially_copyable<value_type>(),
219219
"Can only copy trivially copyable types");
220220
auto size = std::distance(begin, end);
221221
if (size == 0) return;
@@ -249,7 +249,7 @@ namespace Gpu {
249249
void copyAsync (DeviceToHost, InIter begin, InIter end, OutIter result) noexcept
250250
{
251251
using value_type = typename std::iterator_traits<InIter>::value_type;
252-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(value_type),
252+
static_assert(std::is_trivially_copyable<value_type>(),
253253
"Can only copy trivially copyable types");
254254
auto size = std::distance(begin, end);
255255
if (size == 0) return;
@@ -283,7 +283,7 @@ namespace Gpu {
283283
void copyAsync (DeviceToDevice, InIter begin, InIter end, OutIter result) noexcept
284284
{
285285
using value_type = typename std::iterator_traits<InIter>::value_type;
286-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(value_type),
286+
static_assert(std::is_trivially_copyable<value_type>(),
287287
"Can only copy trivially copyable types");
288288
auto size = std::distance(begin, end);
289289
if (size == 0) return;

Src/Base/AMReX_GpuFuse.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct FuseHelper {
3636
int m_N;
3737
};
3838

39-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(FuseHelper),"FuseHelper is not trivially copyable");
39+
static_assert(std::is_trivially_copyable<FuseHelper>(),"FuseHelper is not trivially copyable");
4040

4141
template <typename Lambda>
4242
AMREX_GPU_DEVICE

Src/Base/AMReX_GpuMemory.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct Deleter {
5252
void operator() (void* pt) const noexcept { m_arena->free(pt); }
5353
};
5454

55-
template <class T, typename std::enable_if<AMREX_IS_TRIVIALLY_COPYABLE(T),int>::type = 0>
55+
template <class T, std::enable_if_t<std::is_trivially_copyable<T>::value,int> = 0>
5656
struct DeviceScalar
5757
{
5858
DeviceScalar (DeviceScalar const&) = delete;

Src/Base/AMReX_PODVector.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ namespace amrex
101101
class PODVector : public Allocator
102102
{
103103
// static_assert(std::is_standard_layout<T>(), "PODVector can only hold standard layout types");
104-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(T), "PODVector can only hold trivially copyable types");
104+
static_assert(std::is_trivially_copyable<T>(), "PODVector can only hold trivially copyable types");
105105
// static_assert(std::is_trivially_default_constructible<T>(), "PODVector can only hold trivial dc types");
106106

107107

Src/Base/AMReX_ParallelDescriptor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ BL_FORT_PROC_DECL(BL_PD_ABORT,bl_pd_abort)()
13101310
#if defined(BL_USE_MPI) && !defined(BL_AMRPROF)
13111311
template <> MPI_Datatype Mpi_typemap<IntVect>::type()
13121312
{
1313-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(IntVect), "IntVect must be trivially copyable");
1313+
static_assert(std::is_trivially_copyable<IntVect>::value, "IntVect must be trivially copyable");
13141314
static_assert(std::is_standard_layout<IntVect>::value, "IntVect must be standard layout");
13151315

13161316
if ( mpi_type_intvect == MPI_DATATYPE_NULL )
@@ -1333,7 +1333,7 @@ template <> MPI_Datatype Mpi_typemap<IntVect>::type()
13331333

13341334
template <> MPI_Datatype Mpi_typemap<IndexType>::type()
13351335
{
1336-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(IndexType), "IndexType must be trivially copyable");
1336+
static_assert(std::is_trivially_copyable<IndexType>::value, "IndexType must be trivially copyable");
13371337
static_assert(std::is_standard_layout<IndexType>::value, "IndexType must be standard layout");
13381338

13391339
if ( mpi_type_indextype == MPI_DATATYPE_NULL )
@@ -1356,7 +1356,7 @@ template <> MPI_Datatype Mpi_typemap<IndexType>::type()
13561356

13571357
template <> MPI_Datatype Mpi_typemap<Box>::type()
13581358
{
1359-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(Box), "Box must be trivially copyable");
1359+
static_assert(std::is_trivially_copyable<Box>::value, "Box must be trivially copyable");
13601360
static_assert(std::is_standard_layout<Box>::value, "Box must be standard layout");
13611361

13621362
if ( mpi_type_box == MPI_DATATYPE_NULL )

Src/Base/AMReX_Reduce.H

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ public:
219219
: m_host_tuple(),
220220
m_device_tuple((Type*)(The_Arena()->alloc(2*sizeof(m_host_tuple))))
221221
{
222-
static_assert(AMREX_IS_TRIVIALLY_COPYABLE(Type),
222+
static_assert(std::is_trivially_copyable<Type>(),
223223
"ReduceData::Type must be trivially copyable");
224-
static_assert(std::is_trivially_destructible<Type>::value,
224+
static_assert(std::is_trivially_destructible<Type>(),
225225
"ReduceData::Type must be trivially destructible");
226226

227227
Reduce::detail::for_each_init<0, Type, Ps...>(m_host_tuple);

0 commit comments

Comments
 (0)