fix(memory): fix compile error when memory constructs such as Memory::CopyConstruct for cv qualifiers type
This commit is contained in:
parent
8b902d15a4
commit
8e31a82a1f
@ -165,11 +165,11 @@ void TestMemoryOperator()
|
|||||||
FTracker* PtrB = reinterpret_cast<FTracker*>(Memory::Malloc(sizeof(FTracker)));
|
FTracker* PtrB = reinterpret_cast<FTracker*>(Memory::Malloc(sizeof(FTracker)));
|
||||||
|
|
||||||
FTracker::Status = 0;
|
FTracker::Status = 0;
|
||||||
Memory::DefaultConstruct(PtrA);
|
Memory::DefaultConstruct<FTracker>(PtrA);
|
||||||
always_check(FTracker::Status == -1);
|
always_check(FTracker::Status == -1);
|
||||||
|
|
||||||
FTracker::Status = 1;
|
FTracker::Status = 1;
|
||||||
Memory::Construct(PtrA, PtrB);
|
Memory::Construct<FTracker>(PtrA, PtrB);
|
||||||
always_check(FTracker::Status == -1);
|
always_check(FTracker::Status == -1);
|
||||||
|
|
||||||
FTracker::Status = 1;
|
FTracker::Status = 1;
|
||||||
|
@ -13,15 +13,14 @@ NAMESPACE_BEGIN(Memory)
|
|||||||
|
|
||||||
template <typename ElementType>
|
template <typename ElementType>
|
||||||
requires CDefaultConstructible<ElementType>
|
requires CDefaultConstructible<ElementType>
|
||||||
FORCEINLINE void DefaultConstruct(ElementType* Address, size_t Count = 1)
|
FORCEINLINE void DefaultConstruct(void* Address, size_t Count = 1)
|
||||||
{
|
{
|
||||||
if constexpr (!CTriviallyDefaultConstructible<ElementType>)
|
if constexpr (!CTriviallyDefaultConstructible<ElementType>)
|
||||||
{
|
{
|
||||||
ElementType* Element = Address;
|
|
||||||
while (Count)
|
while (Count)
|
||||||
{
|
{
|
||||||
new (Element) ElementType;
|
new (Address) ElementType;
|
||||||
++Element;
|
++reinterpret_cast<ElementType*&>(Address);
|
||||||
--Count;
|
--Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29,7 +28,7 @@ FORCEINLINE void DefaultConstruct(ElementType* Address, size_t Count = 1)
|
|||||||
|
|
||||||
template <typename DestinationElementType, typename SourceElementType = DestinationElementType>
|
template <typename DestinationElementType, typename SourceElementType = DestinationElementType>
|
||||||
requires CConstructibleFrom<DestinationElementType, const SourceElementType&>
|
requires CConstructibleFrom<DestinationElementType, const SourceElementType&>
|
||||||
FORCEINLINE void Construct(DestinationElementType* Destination, const SourceElementType* Source, size_t Count = 1)
|
FORCEINLINE void Construct(void* Destination, const SourceElementType* Source, size_t Count = 1)
|
||||||
{
|
{
|
||||||
if constexpr (CTriviallyConstructibleFrom<DestinationElementType, const SourceElementType> && sizeof(DestinationElementType) == sizeof(SourceElementType))
|
if constexpr (CTriviallyConstructibleFrom<DestinationElementType, const SourceElementType> && sizeof(DestinationElementType) == sizeof(SourceElementType))
|
||||||
{
|
{
|
||||||
@ -40,7 +39,7 @@ FORCEINLINE void Construct(DestinationElementType* Destination, const SourceElem
|
|||||||
while (Count)
|
while (Count)
|
||||||
{
|
{
|
||||||
new (Destination) DestinationElementType(*Source);
|
new (Destination) DestinationElementType(*Source);
|
||||||
++(DestinationElementType*&)Destination;
|
++reinterpret_cast<DestinationElementType*&>(Destination);
|
||||||
++Source;
|
++Source;
|
||||||
--Count;
|
--Count;
|
||||||
}
|
}
|
||||||
@ -49,7 +48,7 @@ FORCEINLINE void Construct(DestinationElementType* Destination, const SourceElem
|
|||||||
|
|
||||||
template <typename ElementType>
|
template <typename ElementType>
|
||||||
requires CCopyConstructible<ElementType>
|
requires CCopyConstructible<ElementType>
|
||||||
FORCEINLINE void CopyConstruct(ElementType* Destination, const ElementType* Source, size_t Count = 1)
|
FORCEINLINE void CopyConstruct(void* Destination, const ElementType* Source, size_t Count = 1)
|
||||||
{
|
{
|
||||||
if constexpr (CTriviallyCopyConstructible<ElementType>)
|
if constexpr (CTriviallyCopyConstructible<ElementType>)
|
||||||
{
|
{
|
||||||
@ -60,7 +59,7 @@ FORCEINLINE void CopyConstruct(ElementType* Destination, const ElementType* Sour
|
|||||||
while (Count)
|
while (Count)
|
||||||
{
|
{
|
||||||
new (Destination) ElementType(*Source);
|
new (Destination) ElementType(*Source);
|
||||||
++(ElementType*&)Destination;
|
++reinterpret_cast<ElementType*&>(Destination);
|
||||||
++Source;
|
++Source;
|
||||||
--Count;
|
--Count;
|
||||||
}
|
}
|
||||||
@ -69,7 +68,7 @@ FORCEINLINE void CopyConstruct(ElementType* Destination, const ElementType* Sour
|
|||||||
|
|
||||||
template <typename ElementType>
|
template <typename ElementType>
|
||||||
requires CMoveConstructible<ElementType>
|
requires CMoveConstructible<ElementType>
|
||||||
FORCEINLINE void MoveConstruct(ElementType* Destination, ElementType* Source, size_t Count = 1)
|
FORCEINLINE void MoveConstruct(void* Destination, ElementType* Source, size_t Count = 1)
|
||||||
{
|
{
|
||||||
if constexpr (CTriviallyMoveConstructible<ElementType>)
|
if constexpr (CTriviallyMoveConstructible<ElementType>)
|
||||||
{
|
{
|
||||||
@ -80,7 +79,7 @@ FORCEINLINE void MoveConstruct(ElementType* Destination, ElementType* Source, si
|
|||||||
while (Count)
|
while (Count)
|
||||||
{
|
{
|
||||||
new (Destination) ElementType(MoveTemp(*Source));
|
new (Destination) ElementType(MoveTemp(*Source));
|
||||||
++(ElementType*&)Destination;
|
++reinterpret_cast<ElementType*&>(Destination);
|
||||||
++Source;
|
++Source;
|
||||||
--Count;
|
--Count;
|
||||||
}
|
}
|
||||||
@ -120,7 +119,7 @@ FORCEINLINE void MoveAssign(ElementType* Destination, ElementType* Source, size_
|
|||||||
while (Count)
|
while (Count)
|
||||||
{
|
{
|
||||||
*Destination = MoveTemp(*Source);
|
*Destination = MoveTemp(*Source);
|
||||||
++(ElementType*&)Destination;
|
++Destination;
|
||||||
++Source;
|
++Source;
|
||||||
--Count;
|
--Count;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user