10 #ifndef STOKHOS_DYNAMICARRAYTRAITS_HPP
11 #define STOKHOS_DYNAMICARRAYTRAITS_HPP
24 static const bool value =
false;
28 #define STOKHOS_BUILTIN_SPECIALIZATION(t) \
29 template <> struct IsScalarType< t > { \
30 static const bool value = true; \
38 #undef STOKHOS_BUILTIN_SPECIALIZATION
44 template <typename T, bool isScalar = IsScalarType<T>::value>
49 T* m =
static_cast<T*
>(
operator new(sz*
sizeof(T)));
51 for (
int i=0; i<sz; ++i)
61 T* m =
static_cast<T*
>(
operator new(sz*
sizeof(T)));
63 for (
int i=0; i<sz; ++i)
64 new (p++) T(*(src++));
69 static inline void copy(
const T* src, T* dest,
int sz) {
70 for (
int i=0; i<sz; ++i)
75 static inline void zero(T* dest,
int sz) {
76 for (
int i=0; i<sz; ++i)
83 for (T* b = m; b!=e; b++)
85 operator delete((
void*) m);
98 T* m =
static_cast<T*
>(
operator new(sz*
sizeof(T)));
99 std::memset(m,0,sz*
sizeof(T));
108 T* m =
static_cast<T*
>(
operator new(sz*
sizeof(T)));
109 for (
int i=0; i<sz; ++i)
115 static inline void copy(
const T* src, T* dest,
int sz) {
116 std::memcpy(dest,src,sz*
sizeof(T));
120 static inline void zero(T* dest,
int sz) {
121 std::memset(dest,0,sz*
sizeof(T));
126 operator delete((
void*) m);
132 #endif // STOKHOS_DYNAMICARRAYTRAITS_HPP
static void copy(const T *src, T *dest, int sz)
Copy array from src to dest of length sz.
static void zero(T *dest, int sz)
Zero out array dest of length sz.
static T * get_and_fill(const T *src, int sz)
Get memory for new array of length sz and fill with entries from src.
static void destroy_and_release(T *m, int sz)
Destroy array elements and release memory.
static T * get_and_fill(const T *src, int sz)
Get memory for new array of length sz and fill with entries from src.
#define STOKHOS_BUILTIN_SPECIALIZATION(t)
Specialization of above classes to built-in types.
static T * get_and_fill(int sz)
Get memory for new array of length sz and fill with zeros.
static void destroy_and_release(T *m, int sz)
Destroy array elements and release memory.
static T * get_and_fill(int sz)
Get memory for new array of length sz and fill with zeros.
Dynamic array allocation class that works for any type.
static void copy(const T *src, T *dest, int sz)
Copy array from src to dest of length sz.
Base template specification for IsScalarType.
static void zero(T *dest, int sz)
Zero out array dest of length sz.