|
|
@ -499,23 +499,27 @@ namespace df
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
template<class T>
|
|
|
|
typename std::enable_if<
|
|
|
|
typename std::enable_if<
|
|
|
|
std::is_copy_assignable<T>::value
|
|
|
|
std::is_copy_assignable<T>::value,
|
|
|
|
|
|
|
|
void*
|
|
|
|
>::type allocator_try_assign(void *out, const void *in) {
|
|
|
|
>::type allocator_try_assign(void *out, const void *in) {
|
|
|
|
*(T*)out = *(const T*)in;
|
|
|
|
*(T*)out = *(const T*)in;
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
template<class T>
|
|
|
|
typename std::enable_if<
|
|
|
|
typename std::enable_if<
|
|
|
|
!std::is_copy_assignable<T>::value
|
|
|
|
!std::is_copy_assignable<T>::value,
|
|
|
|
|
|
|
|
void*
|
|
|
|
>::type allocator_try_assign(void *out, const void *in) {
|
|
|
|
>::type allocator_try_assign(void *out, const void *in) {
|
|
|
|
// assignment is not possible; do nothing
|
|
|
|
// assignment is not possible; do nothing
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
|
|
|
|
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
|
|
|
|
template<class T>
|
|
|
|
template<class T>
|
|
|
|
void *allocator_fn(void *out, const void *in) {
|
|
|
|
void *allocator_fn(void *out, const void *in) {
|
|
|
|
if (out) { allocator_try_assign<T>(out, in); return out; }
|
|
|
|
if (out) { return allocator_try_assign<T>(out, in); }
|
|
|
|
else if (in) { delete (T*)in; return (T*)in; }
|
|
|
|
else if (in) { delete (T*)in; return (T*)in; }
|
|
|
|
else return new T();
|
|
|
|
else return new T();
|
|
|
|
}
|
|
|
|
}
|
|
|
|