Blender V5.0
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#pragma once
6
7#include <cstring>
8#include <vector>
9
11
13
14/* Own subclass-ed version of std::vector. Subclass is needed because:
15 *
16 * - Use own allocator which keeps track of used/peak memory.
17 * - Have method to ensure capacity is re-set to 0.
18 */
19template<typename value_type, typename allocator_type = GuardedAllocator<value_type>>
20class vector : public std::vector<value_type, allocator_type> {
21 public:
22 using BaseClass = std::vector<value_type, allocator_type>;
23
24 /* Inherit all constructors from base class. */
25 using BaseClass::vector;
26
27 /* Try as hard as possible to use zero memory. */
29 {
31 BaseClass::swap(empty);
32 }
33
34 /* Some external API might demand working with std::vector. */
35 operator std::vector<value_type>()
36 {
37 return std::vector<value_type>(this->begin(), this->end());
38 }
39};
40
iter begin(iter)
std::vector< std::array< const char *, 2 >, GuardedAllocator< std::array< const char *, 2 > > > BaseClass
void free_memory()
#define CCL_NAMESPACE_END