refactor(containers): add the CElementalObject concept to constrain elements
This commit is contained in:
parent
c8650b4aa5
commit
40d27eece6
@ -175,7 +175,7 @@ private:
|
||||
NAMESPACE_PRIVATE_END
|
||||
|
||||
/** 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 <CObject T, typename Allocator = FDefaultAllocator> requires (!CConst<T> && CDestructible<T> && CInstantiableAllocator<Allocator>)
|
||||
template <CElementalObject T, CInstantiableAllocator Allocator = FDefaultAllocator> requires (!CConst<T>)
|
||||
class TArray final
|
||||
{
|
||||
public:
|
||||
|
@ -14,7 +14,7 @@ NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
template <CObject T, size_t InExtent>
|
||||
template <CElementalObject T, size_t InExtent>
|
||||
class TArrayView;
|
||||
|
||||
NAMESPACE_PRIVATE_BEGIN
|
||||
@ -103,7 +103,7 @@ private:
|
||||
template <typename U>
|
||||
friend class TArrayViewIterator;
|
||||
|
||||
template <CObject U, size_t InExtent>
|
||||
template <CElementalObject U, size_t InExtent>
|
||||
friend class NAMESPACE_REDCRAFT::TArrayView;
|
||||
|
||||
};
|
||||
@ -116,10 +116,10 @@ struct TEnableArrayNum<false> { size_t ArrayNum; };
|
||||
|
||||
NAMESPACE_PRIVATE_END
|
||||
|
||||
template <CObject T, size_t N>
|
||||
template <CElementalObject T, size_t N>
|
||||
struct TStaticArray;
|
||||
|
||||
template <CObject T, typename A> requires (!CConst<T> && CDestructible<T> && CInstantiableAllocator<A>)
|
||||
template <CElementalObject T, CInstantiableAllocator A> requires (!CConst<T>)
|
||||
class TArray;
|
||||
|
||||
inline constexpr size_t DynamicExtent = INDEX_NONE;
|
||||
@ -129,7 +129,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
|
||||
* is known at compile-time and encoded in the type, or a dynamic extent.
|
||||
*/
|
||||
template <CObject T, size_t InExtent = DynamicExtent>
|
||||
template <CElementalObject T, size_t InExtent = DynamicExtent>
|
||||
class TArrayView final : private NAMESPACE_PRIVATE::TEnableArrayNum<InExtent == DynamicExtent>
|
||||
{
|
||||
private:
|
||||
|
@ -14,6 +14,9 @@ NAMESPACE_REDCRAFT_BEGIN
|
||||
NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
template <typename T>
|
||||
concept CElementalObject = CObject<T> && CDestructible<T>;
|
||||
|
||||
NAMESPACE_PRIVATE_BEGIN
|
||||
|
||||
template <typename T> using WithReference = T&;
|
||||
|
@ -17,7 +17,7 @@ NAMESPACE_MODULE_BEGIN(Redcraft)
|
||||
NAMESPACE_MODULE_BEGIN(Utility)
|
||||
|
||||
/** TStaticArray is a container that encapsulates fixed size arrays. */
|
||||
template <CObject T, size_t N>
|
||||
template <CElementalObject T, size_t N>
|
||||
struct TStaticArray final
|
||||
{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user