[arrayfire] 24/408: Ensure Array<T> is standard layout using static_asserts

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:11:08 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/sid
in repository arrayfire.

commit f037380c2f9a84d2b05ebe5cecc287073f7c2c60
Author: Umar Arshad <umar at arrayfire.com>
Date:   Sat Jun 20 18:36:53 2015 -0400

    Ensure Array<T> is standard layout using static_asserts
---
 src/backend/cpu/Array.cpp    | 1 +
 src/backend/cuda/Array.cpp   | 3 +++
 src/backend/opencl/Array.cpp | 1 +
 3 files changed, 5 insertions(+)

diff --git a/src/backend/cpu/Array.cpp b/src/backend/cpu/Array.cpp
index 6a4394e..716715a 100644
--- a/src/backend/cpu/Array.cpp
+++ b/src/backend/cpu/Array.cpp
@@ -38,6 +38,7 @@ namespace cpu
         data(memAlloc<T>(dims.elements()), memFree<T>), data_dims(dims),
         node(), ready(true), offset(0), owner(true)
     {
+        static_assert(std::is_standard_layout<Array<T>>::value, "Array<T> must be a standard layout type");
         std::copy(in_data, in_data + dims.elements(), data.get());
     }
 
diff --git a/src/backend/cuda/Array.cpp b/src/backend/cuda/Array.cpp
index 97d67c3..f881fa4 100644
--- a/src/backend/cuda/Array.cpp
+++ b/src/backend/cuda/Array.cpp
@@ -40,6 +40,9 @@ namespace cuda
         data_dims(dims),
         node(), ready(true), offset(0), owner(true)
     {
+#if __cplusplus > 199711L
+        static_assert(std::is_standard_layout<Array<T>>::value, "Array<T> must be a standard layout type");
+#endif
         if (!is_device) {
             CUDA_CHECK(cudaMemcpy(data.get(), in_data, dims.elements() * sizeof(T), cudaMemcpyHostToDevice));
         }
diff --git a/src/backend/opencl/Array.cpp b/src/backend/opencl/Array.cpp
index c1a0e0a..94069a8 100644
--- a/src/backend/opencl/Array.cpp
+++ b/src/backend/opencl/Array.cpp
@@ -51,6 +51,7 @@ namespace opencl
         data_dims(dims),
         node(), ready(true), offset(0), owner(true)
     {
+        static_assert(std::is_standard_layout<Array<T>>::value, "Array<T> must be a standard layout type");
         getQueue().enqueueWriteBuffer(*data.get(), CL_TRUE, 0, sizeof(T)*info.elements(), in_data);
     }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git



More information about the debian-science-commits mailing list