Blender V4.3
cycles/util/vector.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#ifndef __UTIL_VECTOR_H__
6#define __UTIL_VECTOR_H__
7
8#include <cstring>
9#include <vector>
10
11#include "util/aligned_malloc.h"
13
15
16/* Own subclass-ed version of std::vector. Subclass is needed because:
17 *
18 * - Use own allocator which keeps track of used/peak memory.
19 * - Have method to ensure capacity is re-set to 0.
20 */
21template<typename value_type, typename allocator_type = GuardedAllocator<value_type>>
22class vector : public std::vector<value_type, allocator_type> {
23 public:
24 typedef std::vector<value_type, allocator_type> BaseClass;
25
26 /* Inherit all constructors from base class. */
27 using BaseClass::vector;
28
29 /* Try as hard as possible to use zero memory. */
31 {
33 BaseClass::swap(empty);
34 }
35
36 /* Some external API might demand working with std::vector. */
37 operator std::vector<value_type>()
38 {
39 return std::vector<value_type>(this->begin(), this->end());
40 }
41};
42
44
45#endif /* __UTIL_VECTOR_H__ */
std::vector< value_type, allocator_type > BaseClass
void free_memory()
#define CCL_NAMESPACE_END