mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-trx.git
synced 2025-11-02 13:13:17 +00:00
Vector: Copy arrays in a sane way for non-trivially copyable types
Avoids this type of compilation warnings: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class Complex<float>’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess] Change-Id: I9724454dfb7b87f74f39074e4004580ac3b5fe5c
This commit is contained in:
@@ -204,10 +204,15 @@ template <class T> class Vector {
|
||||
*/
|
||||
void copyToSegment(Vector<T>& other, size_t start, size_t span) const
|
||||
{
|
||||
T* base = other.mStart + start;
|
||||
assert(base+span<=other.mEnd);
|
||||
unsigned int i;
|
||||
T* dst = other.mStart + start;
|
||||
T* src = mStart;
|
||||
assert(dst+span<=other.mEnd);
|
||||
assert(mStart+span<=mEnd);
|
||||
memcpy(base,mStart,span*sizeof(T));
|
||||
for (i = 0; i < span; i++, src++, dst++)
|
||||
*dst = *src;
|
||||
/*TODO if not non-trivially copyable type class, optimize:
|
||||
memcpy(dst,mStart,span*sizeof(T)); */
|
||||
}
|
||||
|
||||
/** Copy all of this Vector to a segment of another Vector. */
|
||||
|
||||
Reference in New Issue
Block a user