refactor(*): use CAllocatableObject instead of CElementalObject

This commit is contained in:
_Redstone_c_ 2023-03-22 22:25:12 +08:00
parent ff155e23de
commit 19dc46364a
5 changed files with 16 additions and 16 deletions

View File

@ -17,7 +17,7 @@ NAMESPACE_MODULE_BEGIN(Redcraft)
NAMESPACE_MODULE_BEGIN(Utility) NAMESPACE_MODULE_BEGIN(Utility)
/** Dynamic array. The elements are stored contiguously, which means that elements can be accessed not only through iterators, but also using offsets to regular pointers to elements. */ /** Dynamic array. The elements are stored contiguously, which means that elements can be accessed not only through iterators, but also using offsets to regular pointers to elements. */
template <CElementalObject T, CAllocator<T> Allocator = FHeapAllocator> requires (!CConst<T>) template <CAllocatableObject T, CAllocator<T> Allocator = FHeapAllocator>
class TArray final class TArray final
{ {
private: private:

View File

@ -14,10 +14,10 @@ NAMESPACE_REDCRAFT_BEGIN
NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Redcraft)
NAMESPACE_MODULE_BEGIN(Utility) NAMESPACE_MODULE_BEGIN(Utility)
template <CElementalObject T, size_t N> template <CObject T, size_t N>
struct TStaticArray; struct TStaticArray;
template <CElementalObject T, CAllocator<T> A> requires (!CConst<T>) template <CAllocatableObject T, CAllocator<T> A>
class TArray; class TArray;
inline constexpr size_t DynamicExtent = INDEX_NONE; inline constexpr size_t DynamicExtent = INDEX_NONE;
@ -27,7 +27,7 @@ inline constexpr size_t DynamicExtent = INDEX_NONE;
* the sequence at position zero. A TArrayView can either have a static extent, in which case the number of elements in the sequence * the sequence at position zero. A TArrayView can either have a static extent, in which case the number of elements in the sequence
* is known at compile-time and encoded in the type, or a dynamic extent. * is known at compile-time and encoded in the type, or a dynamic extent.
*/ */
template <CElementalObject T, size_t InExtent = DynamicExtent> template <CObject T, size_t InExtent = DynamicExtent>
class TArrayView final class TArrayView final
{ {
public: public:

View File

@ -14,9 +14,6 @@ NAMESPACE_REDCRAFT_BEGIN
NAMESPACE_MODULE_BEGIN(Redcraft) NAMESPACE_MODULE_BEGIN(Redcraft)
NAMESPACE_MODULE_BEGIN(Utility) NAMESPACE_MODULE_BEGIN(Utility)
template <typename T>
concept CElementalObject = CObject<T> && CDestructible<T>;
NAMESPACE_PRIVATE_BEGIN NAMESPACE_PRIVATE_BEGIN
template <typename T> using WithReference = T&; template <typename T> using WithReference = T&;

View File

@ -17,7 +17,7 @@ NAMESPACE_MODULE_BEGIN(Redcraft)
NAMESPACE_MODULE_BEGIN(Utility) NAMESPACE_MODULE_BEGIN(Utility)
/** TStaticArray is a container that encapsulates fixed size arrays. */ /** TStaticArray is a container that encapsulates fixed size arrays. */
template <CElementalObject T, size_t N> template <CObject T, size_t N>
struct TStaticArray final struct TStaticArray final
{ {
private: private:

View File

@ -12,8 +12,11 @@ NAMESPACE_MODULE_BEGIN(Utility)
struct FAllocatorInterface; struct FAllocatorInterface;
template <typename T>
concept CAllocatableObject = CObject<T> && !CConst<T> && !CVolatile<T>;
template <typename A, typename T = int> template <typename A, typename T = int>
concept CAllocator = !CSameAs<A, FAllocatorInterface> concept CAllocator = !CSameAs<A, FAllocatorInterface> && CAllocatableObject<T>
&& requires (typename A::template ForElementType<T>& Allocator, T* InPtr, size_t Num, size_t NumAllocated) && requires (typename A::template ForElementType<T>& Allocator, T* InPtr, size_t Num, size_t NumAllocated)
{ {
{ Allocator.Allocate(Num) } -> CSameAs<T*>; { Allocator.Allocate(Num) } -> CSameAs<T*>;
@ -43,7 +46,7 @@ struct FAllocatorInterface
*/ */
static constexpr bool bSupportsMultipleAllocation = true; static constexpr bool bSupportsMultipleAllocation = true;
template <CObject T> template <CAllocatableObject T>
class ForElementType /*: private FSingleton*/ class ForElementType /*: private FSingleton*/
{ {
public: public:
@ -114,8 +117,8 @@ struct FHeapAllocator
{ {
static constexpr bool bSupportsMultipleAllocation = true; static constexpr bool bSupportsMultipleAllocation = true;
template <CObject T> template <CAllocatableObject T>
class ForElementType class ForElementType /*: private FSingleton*/
{ {
public: public:
@ -193,8 +196,8 @@ struct TInlineAllocator
{ {
static constexpr bool bSupportsMultipleAllocation = false; static constexpr bool bSupportsMultipleAllocation = false;
template <CObject T> template <CAllocatableObject T>
class ForElementType class ForElementType /*: private FSingleton*/
{ {
public: public:
@ -275,8 +278,8 @@ struct FNullAllocator
{ {
static constexpr bool bSupportsMultipleAllocation = true; static constexpr bool bSupportsMultipleAllocation = true;
template <CObject T> template <CAllocatableObject T>
class ForElementType class ForElementType /*: private FSingleton*/
{ {
public: public: