23#if MOCHI_LANGUAGE_CPP20
37#ifndef MOCHI_DARRAY_DEBUG
38#define MOCHI_DARRAY_DEBUG MOCHI_DEBUG
41#if MOCHI_DARRAY_DEBUG && MOCHI_ASSERT_ENABLED
42#define MOCHI_DARRAY_ASSERT(cond, ...) MOCHI_ASSERT(cond, __VA_ARGS__)
44#define MOCHI_DARRAY_ASSERT(cond, ...)
47#if MOCHI_LANGUAGE_CPP20
50template <
class From,
class To>
52 std::is_convertible_v<From, To> &&
requires {
static_cast<To
>(std::declval<From>()); };
57#define MOCHI_DARRAY_ASSERT_FORWARD_ITERATOR(IteratorType) \
59 HasDistance<IteratorType>, \
60 "This type of input iterator is not supported by DynamicArray because there is no way to " \
61 "reserve sufficient memory up front. We would have to loop calling emplace_back, which " \
62 "would be inefficient. Consider initializing this DynamicArray in a different way.");
64#define MOCHI_DARRAY_ASSERT_FORWARD_ITERATOR(IteratorType) \
67 std::forward_iterator_tag, \
68 typename std::iterator_traits<IteratorType>::iterator_category>, \
69 "This type of input iterator is not supported by DynamicArray because there is no way to " \
70 "reserve sufficient memory up front. We would have to loop calling emplace_back, which " \
71 "would be inefficient. Consider initializing this DynamicArray in a different way.");
108 !std::is_same_v<T, Allocator> && !std::is_same_v<T, Allocator*>,
109 "DynamicArray of allocators is not allowed because of overload ambiguity.");
136 : _allocator(allocator) {
138 _begin =
static_cast<T*
>(allocator->allocate(
size *
sizeof(T),
alignof(T)));
139 _end = _endCapacity = _begin +
size;
140 DefaultConstructRange(_begin, _end);
152 template <
typename FromT, MOCHI_CONCEPT((std::is_convertible_v<FromT, T>))>
155 FromT
const& defaultValue,
157 : _allocator(allocator) {
159 _begin =
static_cast<T*
>(allocator->allocate(
size *
sizeof(T),
alignof(T)));
160 _end = _endCapacity = _begin +
size;
161 CopyConstructRangeFromValue(_begin, _end, defaultValue);
177 std::input_iterator_tag,
178 typename std::iterator_traits<InputIt>::iterator_category>))>
180 : _allocator(allocator) {
182 auto size =
static_cast<size_type>(std::distance(rangeBegin, rangeEnd));
184 _begin =
static_cast<T*
>(allocator->allocate(
size *
sizeof(T),
alignof(T)));
185 _end = _endCapacity = _begin +
size;
186 CopyConstructRange(_begin, rangeBegin, rangeEnd);
208 typename InputContainerT,
210 (!std::is_same_v<std::decay_t<InputContainerT>,
DynamicArray> &&
211 sizeof(
decltype(std::begin(std::declval<InputContainerT const&>()))) &&
212 sizeof(
decltype(std::end(std::declval<InputContainerT const&>())))))>
245 if (other._allocator->is_equal(*_allocator))
MOCHI_LIKELY {
246 _begin = other._begin;
248 _endCapacity = other._endCapacity;
249 other._begin = other._end = other._endCapacity = nullptr;
250 }
else if (!other.empty()) {
251 auto size = other.size();
252 _begin = static_cast<T*>(_allocator->allocate(size * sizeof(T), alignof(T)));
254 _endCapacity = _begin + size;
257 for (auto src = other._begin; src < other._end; ++src, ++_end) {
258 new (_end) T(std::move(*src));
272 : _begin(other._begin),
274 _endCapacity(other._endCapacity),
275 _allocator(other._allocator) {
276 other._begin = other._end = other._endCapacity =
nullptr;
284 if (_begin !=
nullptr) {
285 DestroyRange(_begin, _end);
286 _allocator->deallocate(_begin,
capacity() *
sizeof(T),
alignof(T));
287#if MOCHI_DARRAY_DEBUG
288 _begin = _end = _endCapacity =
nullptr;
289 _allocator =
nullptr;
386 return _end - _begin;
393 return _endCapacity - _begin;
400 return _end == _begin;
414 if (newSize >
size()) {
416 GrowCapacity(_begin ? GetNextCapacity(newSize) : newSize);
418 DefaultConstructRange(_end, _begin + newSize);
420 DestroyRange(_begin + newSize, _end);
422 _end = _begin + newSize;
440 if (newSize >
size()) {
442 GrowCapacity(_begin ? GetNextCapacity(newSize) : newSize);
444 CopyConstructRangeFromValue(_end, _begin + newSize, value);
446 DestroyRange(_begin + newSize, _end);
448 _end = _begin + newSize;
468 if (newSize > prevSize) {
470 GrowCapacity(_begin ? GetNextCapacity(newSize) : newSize);
472 _end = _begin + newSize;
473 DebugFillWithNaN(_begin + prevSize, _end);
475 DestroyRange(_begin + newSize, _end);
476 _end = _begin + newSize;
490 template <
typename... Args>
506 GrowCapacity(newCapacity);
515 DestroyRange(_begin, _end);
523 if (_endCapacity > _end) {
525 _allocator->deallocate(_begin,
capacity() *
sizeof(T),
alignof(T));
526 _begin = _end = _endCapacity =
nullptr;
528 auto const n =
size();
529 auto* newBegin =
static_cast<T*
>(_allocator->allocate(n *
sizeof(T),
alignof(T)));
530 MoveConstructRange(newBegin, _begin, n);
531 DestroyRange(_begin, _end);
532 _allocator->deallocate(_begin,
capacity() *
sizeof(T),
alignof(T));
534 _end = _endCapacity = newBegin + n;
555 template <
class... Args>
557 if constexpr (
sizeof...(Args) == 1) {
558 if constexpr (std::is_same_v<
560 std::remove_cv_t<std::remove_reference_t<decltype(std::get<0>(
561 std::forward_as_tuple(args...)))>>>) {
563 !IsInThisArray(&std::get<0>(std::forward_as_tuple(args...))),
564 "You are not allowed to push an element of a DynamicArray onto the end of the same DynamicArray. "
565 "Consider pushing a copy of the value instead.");
569 GrowCapacity(GetNextCapacity(
size() + 1));
571 new (_end) T(std::forward<Args>(args)...);
627 if constexpr (!std::is_trivially_destructible_v<T>) {
644 auto rangeBegin =
const_cast<iterator>(rangeBegin_);
645 auto rangeEnd =
const_cast<iterator>(rangeEnd_);
646 if (rangeEnd == _end) {
649 DestroyRange(rangeBegin, rangeEnd);
651 }
else if (rangeEnd != rangeBegin) {
655 if constexpr (std::is_trivially_move_assignable_v<T>) {
656 memmove(rangeBegin, rangeEnd, (_end - rangeEnd) *
sizeof(T));
659 T* src =
const_cast<T*
>(rangeEnd);
660 for (; src != _end; ++dst, ++src) {
661 *dst = std::move(*src);
664 auto numRemoved = (rangeEnd - rangeBegin);
665 auto newSize =
size() - numRemoved;
666 DestroyRange(_begin + newSize, _end);
667 _end = _begin + newSize;
679 auto it =
const_cast<iterator>(it_);
681 if (it + 1 == _end) {
698 auto* last = _end - 1;
700 *it = std::move(*last);
719 std::input_iterator_tag,
720 typename std::iterator_traits<InputIt>::iterator_category>))>
721 void assign(InputIt rangeBegin, InputIt rangeEnd) {
723 if constexpr (std::is_pointer_v<InputIt>) {
726 !IsInThisArray(rangeBegin, rangeEnd),
727 "The input range is not allowed to point to memory within the DynamicArray that is being modified.");
729 auto const oldSize =
size();
730 auto const newSize =
static_cast<size_type>(std::distance(rangeBegin, rangeEnd));
732 _allocator || (newSize == oldSize),
733 "It is illegal to change the size of a DynamicArray that does not own the memory.");
734 if (newSize <= oldSize) {
736 _end = _begin + newSize;
737 DestroyRange(_begin + newSize, _begin + oldSize);
738 std::copy(rangeBegin, rangeEnd, _begin);
741 _end += (newSize - oldSize);
742 if constexpr (std::is_trivially_copyable_v<T>) {
745 std::copy(rangeBegin, rangeEnd, _begin);
748 auto src = rangeBegin;
749 std::copy_n(src, oldSize, _begin);
751 std::advance(src, oldSize);
752 for (
size_type i = oldSize; i < newSize; ++i, ++src) {
753 new (_begin + i) T(*src);
759 std::is_trivially_copyable_v<T> && std::is_trivially_move_constructible_v<T> &&
760 std::is_trivially_move_assignable_v<T> && std::is_trivially_destructible_v<T>) {
765 _allocator->deallocate(_begin,
capacity() *
sizeof(T),
alignof(T));
767 _begin =
static_cast<T*
>(_allocator->allocate(newSize *
sizeof(T),
alignof(T)));
768 _end = _endCapacity = _begin + newSize;
769 std::copy(rangeBegin, rangeEnd, _begin);
772 GrowCapacity(newSize);
773 _end = _begin + newSize;
775 auto src = rangeBegin;
776 std::copy_n(src, oldSize, _begin);
778 std::advance(src, oldSize);
779 CopyConstructRange(_begin + oldSize, src, rangeEnd);
795 template <
class InputIt>
796 void append(InputIt rangeBegin, InputIt rangeEnd) {
799 !IsInThisArray(rangeBegin, rangeEnd),
800 "The input range is not allowed to point to memory within the DynamicArray that is being modified.");
801 auto count = std::distance(rangeBegin, rangeEnd);
803 auto prevSize =
size();
804 auto newSize = prevSize + count;
806 GrowCapacity(GetNextCapacity(newSize));
808 _end = _begin + newSize;
809 CopyConstructRange(_begin + prevSize, rangeBegin, rangeEnd);
822 template <
class InputContainerT>
824 append(std::begin(container), std::end(container));
879 if (_allocator->is_equal(*other._allocator))
MOCHI_LIKELY {
881 if (_begin !=
nullptr) {
882 _allocator->deallocate(_begin,
capacity() *
sizeof(T),
alignof(T));
885 _begin = other._begin;
887 _endCapacity = other._endCapacity;
888 other._begin = other._end = other._endCapacity =
nullptr;
889 }
else if (!other.empty()) {
891 auto const newSize = other.size();
893 GrowCapacity(newSize);
898 for (
auto src = other._begin; src < other._end; ++src, ++_end) {
899 new (_end) T(std::move(*src));
917 assign(std::begin(list), std::end(list));
930 typename InputContainerT,
932 (!std::is_same_v<std::decay_t<InputContainerT>,
DynamicArray> &&
933 sizeof(
decltype(std::begin(std::declval<InputContainerT const&>()))) &&
934 sizeof(
decltype(std::end(std::declval<InputContainerT const&>())))))>
936 assign(std::begin(other), std::end(other));
945 if (other.
size() == s) {
947 if (other._begin[i] != _begin[i]) {
962 return !(*
this == other);
966 void GrowCapacity(size_type newCapacity) {
971 _allocator->deallocate(_begin, capacity() *
sizeof(T),
alignof(T));
973 _begin = _end =
static_cast<T*
>(_allocator->allocate(newCapacity *
sizeof(T),
alignof(T)));
974 _endCapacity = _begin + newCapacity;
976 auto oldSize = size();
977 auto* newBegin =
static_cast<T*
>(_allocator->allocate(newCapacity *
sizeof(T),
alignof(T)));
978 for (
auto i =
static_cast<ptrdiff_t
>(oldSize) - 1; i >= 0; --i) {
979 new (&newBegin[i]) T(std::move(_begin[i]));
980 if constexpr (!std::is_trivially_destructible_v<T>) {
984 _allocator->deallocate(_begin, capacity() *
sizeof(T),
alignof(T));
986 _end = newBegin + oldSize;
987 _endCapacity = newBegin + newCapacity;
991 size_type GetNextCapacity(size_type minCapacity)
const {
993 return std::max(std::max(minCapacity, kGrowthPatternStartSize), capacity() * 3 / 2);
996 static void DebugFillWithNaN(
997 [[maybe_unused]]
void* rangeBegin,
998 [[maybe_unused]]
void const* rangeEnd) {
999#if MOCHI_DARRAY_DEBUG
1002 auto fillBeginAddr =
1003 Min(
reinterpret_cast<size_type
>(rangeEnd),
1004 RoundUp(
reinterpret_cast<size_type
>(rangeBegin),
alignof(
real)));
1006 Max(
reinterpret_cast<size_type
>(rangeBegin),
1007 RoundDown(
reinterpret_cast<size_type
>(rangeEnd),
alignof(
real)));
1008 auto* fillBegin =
reinterpret_cast<std::byte*
>(fillBeginAddr);
1009 auto* fillEnd =
reinterpret_cast<std::byte*
>(fillEndAddr);
1010 auto const nan = std::numeric_limits<real>::signaling_NaN();
1011 for (
auto it = fillBegin; it < fillEnd; it +=
sizeof(nan)) {
1013 memcpy(it, &nan,
sizeof(nan));
1017 auto paddingSizeFront = fillBegin -
reinterpret_cast<std::byte*
>(rangeBegin);
1018 if (paddingSizeFront) {
1019 memset(rangeBegin, 0, paddingSizeFront);
1021 auto paddingSizeBack =
reinterpret_cast<std::byte const*
>(rangeEnd) - fillEnd;
1022 if (paddingSizeBack) {
1023 memset(fillEnd, 0, paddingSizeBack);
1028 static void DefaultConstructRange(T* rangeBegin, T
const* rangeEnd) {
1029 if constexpr (std::is_trivially_default_constructible_v<T>) {
1031 reinterpret_cast<std::intptr_t
>(rangeEnd) -
reinterpret_cast<std::intptr_t
>(rangeBegin);
1032 memset(rangeBegin, 0, numBytes);
1034 for (
auto* it = rangeBegin; it < rangeEnd; ++it) {
1040#if MOCHI_COMPILER_MSVC
1046 static void CopyConstructRangeFromValue(T* rangeBegin, T
const* rangeEnd, T
const& value) {
1047 for (
auto* it = rangeBegin; it < rangeEnd; ++it) {
1052 template <
class InputIt>
1053 static void CopyConstructRange(T* dstBegin, InputIt srcBegin, InputIt srcEnd) {
1055 using SrcT = std::remove_cv_t<typename std::iterator_traits<InputIt>::value_type>;
1057 std::is_trivially_copyable_v<T> && std::is_copy_assignable_v<T> &&
1058 std::is_same_v<SrcT, T>) {
1059 std::copy(srcBegin, srcEnd, dstBegin);
1061 auto src = srcBegin;
1062 auto dst = dstBegin;
1063 for (; src != srcEnd; ++src, ++dst) {
1069 static void MoveConstructRange(T* dstBegin, T* srcBegin, size_type count) {
1070 if constexpr (std::is_trivially_move_constructible_v<T>) {
1072 memcpy(dstBegin, srcBegin, count *
sizeof(T));
1075 for (
auto i = 0; i < count; ++i) {
1076 new (&dstBegin[i]) T(std::move(srcBegin[i]));
1081 static void Destroy(T* it) {
1082 if constexpr (!std::is_trivially_destructible_v<T>) {
1085 DebugFillWithNaN(it, it + 1);
1088 static void DestroyRange(T* rangeBegin, T
const* rangeEnd) {
1089 if constexpr (!std::is_trivially_destructible_v<T>) {
1092 auto* it =
const_cast<T*
>(rangeEnd);
1093 while (it != rangeBegin) {
1099 DebugFillWithNaN(rangeBegin, rangeEnd);
1102#if MOCHI_DARRAY_DEBUG
1103 template <
class InputIt>
1104 bool IsInThisArray(InputIt rangeBegin, InputIt rangeEnd)
const {
1105 if constexpr (std::is_pointer_v<std::remove_reference_t<InputIt>>) {
1108 (
reinterpret_cast<T const*
>(rangeBegin)) >= _endCapacity ||
1109 (
reinterpret_cast<T const*
>(rangeEnd) <= _begin));
1117 bool IsInThisArray(T
const* ptr)
const {
1118 return (ptr >= _begin) && (ptr < _end);
1123 static constexpr size_type kGrowthPatternStartSize = 8;
1125 T* _begin =
nullptr;
1127 T* _endCapacity =
nullptr;
1136template <
typename T,
typename InBeginIterator,
typename InEndIterator>
1139 out.
append(inBegin, inEnd);
1143template <
typename T,
typename InContainer>
1145 out.
append(std::begin(inContainer), std::end(inContainer));
1150template <
typename T,
typename ContainerIn>
1152 if (valueToAdd == T(0)) {
1155 auto outIndex = out.
size();
1157 for (
auto const& x : in) {
1158 out[outIndex++] = x + valueToAdd;
1168template <
class ContainerT>
1169struct IsDynamicArrayDef :
public std::false_type {};
1171struct IsDynamicArrayDef<
DynamicArray<T>> :
public std::true_type {};
1175template <
class ContainerT>
1176static constexpr bool kIsDynamicArray =
1177 superdex::details::IsDynamicArrayDef<std::decay_t<ContainerT>>::value;
1183 std::input_iterator_tag,
1184 typename std::iterator_traits<InputIt>::iterator_category>))>
1191#if MOCHI_USE_REFLECTION
1192namespace superdex::details {
1201class DynamicArrayTypeInfo final :
public SReflect::ArrayTypeInfo {
1203 [[nodiscard]]
bool CanResize()
const override {
1207 size_t GetNumElements(
void const* obj)
const override {
1208 return Get(obj).size();
1211 bool SetNumElements(
void* obj,
size_t numElements)
const override {
1212 Get(obj).resize(numElements);
1216 void* GetElement(
void* obj,
size_t i)
const override {
1217 return &Get(obj)[i];
1220 void const* GetElement(
void const* obj,
size_t i)
const override {
1221 return &Get(obj)[i];
1224 [[nodiscard]]
bool IsMemCopySafe()
const override {
1229 bool SerializeToBytesInner(
void const* src, SReflect::StreamWriter& dst)
const override {
1230 if constexpr (std::is_trivially_copyable_v<T>) {
1231 if (_innerTypeInfo->IsMemCopySafe()) {
1232 auto const& arr = Get(src);
1233 size_t const numElements = arr.size();
1235 return dst.Write(&numElements,
sizeof(numElements)) &&
1236 (numElements == 0 || dst.Write(arr.data(), numElements *
sizeof(T)));
1239 return ArrayTypeInfo::SerializeToBytesInner(src, dst);
1242 bool DeserializeFromBytesInner(SReflect::StreamReader& src,
void* dst)
const override {
1243 if constexpr (std::is_trivially_copyable_v<T>) {
1244 if (_innerTypeInfo->IsMemCopySafe()) {
1245 size_t numElements = 0;
1247 if (!src.Read(&numElements,
sizeof(numElements)) ||
1248 numElements > std::numeric_limits<size_t>::max() /
sizeof(T)) {
1251 auto& arr = Get(dst);
1252 arr.resize_noinit(numElements);
1253 return numElements == 0 || src.Read(arr.data(), numElements *
sizeof(T));
1256 return ArrayTypeInfo::DeserializeFromBytesInner(src, dst);
1260 static DynamicArray<T>& Get(
void* obj) {
1261 return *
static_cast<DynamicArray<T>*
>(obj);
1264 static DynamicArray<T>
const& Get(
void const* obj) {
1265 return *
static_cast<DynamicArray<T> const*
>(obj);
1273 static constexpr SReflect::CoreType coreType = SReflect::CoreType::CT_array;
1274 static SReflect::ArrayTypeInfo
const& GetTypeInfo() {
1276 static auto* s_typeInfo =
1277 SReflect::MakeDynamicArrayTypeInfo<superdex::details::DynamicArrayTypeInfo<T>, ArrT, T>(
1278 "superdex::DynamicArray",
true);
Virtual interface class for memory allocation and deallocation.
A dynamically resizable array with syntax and behavior similar to std::pmr::vector.
DynamicArray()=default
Construct an empty DynamicArray with the default allocator.
DynamicArray(size_type size, FromT const &defaultValue, Allocator *allocator=GetDefaultAllocator())
Construct a DynamicArray filled with copies of the specified value.
size_type size() const
Get the number of elements in the array.
void append(InputIt rangeBegin, InputIt rangeEnd)
Add values to the end of this DynamicArray by copying them from the half-open range [rangeBegin,...
T const & back() const
Get a const reference to the last element.
const_iterator cbegin() const
Get a const iterator pointing to the beginning of the array.
DynamicArray(DynamicArray const &other)
Copy construct from another DynamicArray.
T & push_back()
Default construct a new element at the end of the array.
void reset(Args &&... args)
Reset the state of this DynamicArray using the arguments from any constructor.
iterator begin()
Get an iterator pointing to the beginning of the array.
void resize_noinit(size_type newSize)
Set the size but do not initialize any new elements.
DynamicArray & operator=(DynamicArray const &other)
Copy Assignment: Replace the contents of this DynamicArray by copying values from another one.
void push_back(T &&value)
Move the value to a new element at the end of the array.
DynamicArray & operator=(std::initializer_list< T > const &list)
Copy Assignment: Replace the contents of this DynamicArray by copying values from a std::initializer_...
Allocator * get_allocator() const
Get a pointer to the polymorphic allocator.
void resize(size_type newSize)
Set the size.
void resize(size_type newSize, T const &value)
Set the size.
T & operator[](size_type i)
Get a reference to the value at index i.
DynamicArray(size_type size, Allocator *allocator=GetDefaultAllocator())
Construct a DynamicArray with an initial size.
DynamicArray & operator=(DynamicArray &&other)
Move Assignment: Replace the contents of this DynamicArray by moving memory or values from another on...
bool operator==(DynamicArray const &other) const
Comparison returns true if the other array has the same size and all values are equal.
T const & front() const
Get a const reference to the first element.
DynamicArray(std::initializer_list< T > const &list, Allocator *allocator=GetDefaultAllocator())
Construct a DynamicArray and copy values from a std::initializer_list.
T const & operator[](size_type i) const
Get a reference to the value at index i.
T const * data() const
Get a const pointer to the first element.
T * data()
Get a pointer to the first element.
void erase(const_iterator it_)
Remove one element from this array.
void pop_back()
Remove the last element of the array (must not be empty).
void push_back(T const &value)
Copy the value to a new element at the end of the array.
void erase(const_iterator rangeBegin_, const_iterator rangeEnd_)
Remove the half-open range [rangeBegin, rangeEnd) from this array.
void assign(InputIt rangeBegin, InputIt rangeEnd)
Replace the contents of this DynamicArray by copying values from the half-open range [rangeBegin,...
const_iterator cend() const
Get a const iterator pointing to the next element AFTER the end of the array.
void erase_unordered(iterator it)
Remove one element from this array and swap the last element into its place.
DynamicArray(DynamicArray &&other) noexcept
Move construct from another DynamicArray.
bool empty() const
Return true if the array is empty (zero size).
size_type capacity() const
Get the number of elements that could fit in the array without allocating more memory.
DynamicArray(DynamicArray const &other, Allocator *allocator)
Construct a DynamicArray and copy values from another one.
const_iterator end() const
Get a const iterator pointing to the next element AFTER the end of the array.
void clear()
Set the size to zero.
void shrink_to_fit()
Ensure that the capacity (memory allocated) is no larger than the size (memory used).
bool operator!=(DynamicArray const &other) const
Comparison returns false unless the other array has the same size and all values are equal.
T & front()
Get a reference to the first element.
iterator end()
Get an iterator pointing to the next element AFTER the end of the array.
DynamicArray(Allocator *allocator)
Construct an empty DynamicArray with a specific allocator.
T & back()
Get a reference to the last element.
void reserve(size_type newCapacity)
Ensure that this array has at least the specified capacity.
DynamicArray & operator=(InputContainerT const &other)
Copy Assignment: Replace the contents of this DynamicArray by copying values from another iterable co...
~DynamicArray()
Destroy the DynamicArray object and all of its elements.
DynamicArray(InputIt rangeBegin, InputIt rangeEnd, Allocator *allocator=GetDefaultAllocator())
Construct a DynamicArray and copy values from the half-open range: [rangeBegin, rangeEnd).
DynamicArray(DynamicArray &&other, Allocator *allocator)
Construct a DynamicArray by moving memory or values from another one.
void emplace_back(Args &&... args)
Emplace a new element at the end of the array.
DynamicArray(InputContainerT const &other, Allocator *allocator=GetDefaultAllocator())
Construct a DynamicArray and copy values from another iterable container type like superdex::Span,...
void append(InputContainerT const &container)
Add values to the end of this DynamicArray by copying them from another iterable container.
const_iterator begin() const
Get a const iterator pointing to the beginning of the array.
#define MOCHI_DARRAY_ASSERT_FORWARD_ITERATOR(IteratorType)
#define MOCHI_DARRAY_ASSERT(cond,...)
constexpr T const & Min(T const &a, T const &b)
constexpr T RoundDown(T numToRound, T multiple)
constexpr T RoundUp(T numToRound, T multiple)
void Append(DynamicArray< T > &out, InBeginIterator const &inBegin, InEndIterator const &inEnd)
Utility Functions.
constexpr bool kIsResizeNoInitSafe
Helper variable template for IsResizeNoInitSafe.
DynamicArray(InputIt, InputIt, Allocator *=GetDefaultAllocator()) -> DynamicArray< typename std::iterator_traits< InputIt >::value_type >
Allocator * GetDefaultAllocator()
Get an instance of the DefaultAllocator class.
constexpr T const & Max(T const &a, T const &b)
void AppendSum(DynamicArray< T > &out, ContainerIn const &in, T valueToAdd)
Trait to determine if a type is safe for use with DynamicArray::resize_noinit.