44 #ifndef STOKHOS_DYNAMICARRAYTRAITS_HPP
45 #define STOKHOS_DYNAMICARRAYTRAITS_HPP
58 static const bool value =
false;
62 #define STOKHOS_BUILTIN_SPECIALIZATION(t) \
63 template <> struct IsScalarType< t > { \
64 static const bool value = true; \
72 #undef STOKHOS_BUILTIN_SPECIALIZATION
78 template <typename T, bool isScalar = IsScalarType<T>::value>
83 T* m =
static_cast<T*
>(
operator new(sz*
sizeof(T)));
85 for (
int i=0; i<sz; ++i)
95 T* m =
static_cast<T*
>(
operator new(sz*
sizeof(T)));
97 for (
int i=0; i<sz; ++i)
98 new (p++) T(*(src++));
103 static inline void copy(
const T* src, T* dest,
int sz) {
104 for (
int i=0; i<sz; ++i)
105 *(dest++) = *(src++);
109 static inline void zero(T* dest,
int sz) {
110 for (
int i=0; i<sz; ++i)
117 for (T* b = m; b!=e; b++)
119 operator delete((
void*) m);
127 template <
typename T>
132 T* m =
static_cast<T*
>(
operator new(sz*
sizeof(T)));
133 std::memset(m,0,sz*
sizeof(T));
142 T* m =
static_cast<T*
>(
operator new(sz*
sizeof(T)));
143 for (
int i=0; i<sz; ++i)
149 static inline void copy(
const T* src, T* dest,
int sz) {
150 std::memcpy(dest,src,sz*
sizeof(T));
154 static inline void zero(T* dest,
int sz) {
155 std::memset(dest,0,sz*
sizeof(T));
160 operator delete((
void*) m);
166 #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.