Blender
V5.0
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
#pragma once
6
7
#include <cstring>
8
#include <vector>
9
10
#include "
util/guarded_allocator.h
"
11
12
CCL_NAMESPACE_BEGIN
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
*/
19
template
<
typename
value_type,
typename
allocator_type = GuardedAllocator<value_type>>
20
class
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. */
28
void
free_memory
()
29
{
30
vector<value_type, allocator_type>
empty;
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
41
CCL_NAMESPACE_END
begin
iter begin(iter)
vector
Definition
cycles/util/vector.h:20
vector< std::array< const char *, 2 > >::BaseClass
std::vector< std::array< const char *, 2 >, GuardedAllocator< std::array< const char *, 2 > > > BaseClass
Definition
cycles/util/vector.h:22
vector::free_memory
void free_memory()
Definition
cycles/util/vector.h:28
CCL_NAMESPACE_END
#define CCL_NAMESPACE_END
Definition
device/cuda/compat.h:10
guarded_allocator.h
CCL_NAMESPACE_BEGIN
Definition
python.cpp:37
Generated on
for Blender by
doxygen
1.16.1