Files
henrik karlsson f027bfa856 [Core]
* Fixed compile errors when compiling .h files in isolation

#rb none

[CL 25865668 by henrik karlsson in ue5-main branch]
2023-06-08 02:30:27 -04:00

56 lines
1.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Containers/Array.h"
#include "Templates/TypeCompatibleBytes.h"
namespace Metasound
{
template<typename ElementType, int32 NumInlineElements>
class TParamPackFixedArray
{
public:
TParamPackFixedArray(const TArray<ElementType>& Other)
{
*this = Other;
}
TParamPackFixedArray<ElementType, NumInlineElements>& operator=(const TArray<ElementType>& Other)
{
int32 NumToCopy = FMath::Min(Other.Num(), NumInlineElements);
for (int32 i = 0; i < NumToCopy; ++i)
{
GetData()[i] = Other[i];
}
NumValidElements = NumToCopy;
return *this;
}
void CopyToArray(TArray<ElementType>& Dest) const
{
Dest.Empty();
for (int32 i = 0; i < NumValidElements; ++i)
{
Dest.Add(GetData()[i]);
}
}
FORCEINLINE const ElementType* GetData() const
{
return (ElementType*)InlineData;
}
FORCEINLINE ElementType* GetData()
{
return (ElementType*)InlineData;
}
public:
int32 NumValidElements = 0;
using FByteBucketType = TTypeCompatibleBytes<ElementType>;
FByteBucketType InlineData[NumInlineElements];
};
}