Blender
V4.3
intern
cycles
util
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
"
12
#include "
util/guarded_allocator.h
"
13
14
CCL_NAMESPACE_BEGIN
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
*/
21
template
<
typename
value_type,
typename
allocator_type = GuardedAllocator<value_type>>
22
class
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. */
30
void
free_memory
()
31
{
32
vector<value_type, allocator_type>
empty;
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
43
CCL_NAMESPACE_END
44
45
#endif
/* __UTIL_VECTOR_H__ */
vector
Definition
cycles/util/vector.h:22
vector::BaseClass
std::vector< value_type, allocator_type > BaseClass
Definition
cycles/util/vector.h:24
vector::free_memory
void free_memory()
Definition
cycles/util/vector.h:30
aligned_malloc.h
CCL_NAMESPACE_END
#define CCL_NAMESPACE_END
Definition
device/cuda/compat.h:10
guarded_allocator.h
CCL_NAMESPACE_BEGIN
Definition
python.cpp:44
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0