diff --git a/renderdoc/api/replay/basic_types.h b/renderdoc/api/replay/basic_types.h index 0b21c1d2f..c9b5c33a3 100644 --- a/renderdoc/api/replay/basic_types.h +++ b/renderdoc/api/replay/basic_types.h @@ -89,6 +89,22 @@ struct null_terminator inline static void fixup(char *elems, size_t count) { elems[count] = 0; } }; +template ::value> +struct ItemHelper +{ + static void initRange(T *first, int32_t count) + { + for(int32_t i = 0; i < count; i++) + new(first + i) T(); + } +}; + +template +struct ItemHelper +{ + static void initRange(T *first, int32_t itemCount) { memset(first, 0, itemCount * sizeof(T)); } +}; + template struct rdcarray { @@ -222,8 +238,7 @@ public: setUsedCount((int32_t)s); // default initialise the new elements - for(int32_t i = oldCount; i < usedCount; i++) - new(elems + i) T(); + ItemHelper::initRange(elems + oldCount, usedCount - oldCount); } else {