grpc
third_party
bloaty
third_party
re2
util
bloaty/third_party/re2/util/pod_array.h
Go to the documentation of this file.
1
// Copyright 2018 The RE2 Authors. All Rights Reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
5
#ifndef UTIL_POD_ARRAY_H_
6
#define UTIL_POD_ARRAY_H_
7
8
#include <memory>
9
#include <type_traits>
10
11
namespace
re2
{
12
13
template
<
typename
T>
14
class
PODArray
{
15
public
:
16
static_assert(
std::is_pod<T>::value
,
17
"T must be POD"
);
18
19
PODArray
()
20
:
ptr_
() {}
21
explicit
PODArray
(
int
len
)
22
:
ptr_
(
std
::allocator<
T
>().allocate(
len
), Deleter(
len
)) {}
23
24
T
*
data
()
const
{
25
return
ptr_
.get();
26
}
27
28
int
size
()
const
{
29
return
ptr_
.get_deleter().len_;
30
}
31
32
T
&
operator[]
(
int
pos
)
const
{
33
return
ptr_
[
pos
];
34
}
35
36
private
:
37
struct
Deleter
{
38
Deleter
()
39
:
len_
(0) {}
40
explicit
Deleter
(
int
len
)
41
:
len_
(
len
) {}
42
43
void
operator()
(
T
*
ptr
)
const
{
44
std::allocator<T>().deallocate(
ptr
,
len_
);
45
}
46
47
int
len_
;
48
};
49
50
std::unique_ptr<T[], Deleter>
ptr_
;
51
};
52
53
}
// namespace re2
54
55
#endif // UTIL_POD_ARRAY_H_
ptr
char * ptr
Definition:
abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
pos
int pos
Definition:
libuv/docs/code/tty-gravity/main.c:11
re2::PODArray::Deleter
Definition:
bloaty/third_party/re2/util/pod_array.h:37
re2::PODArray::PODArray
PODArray()
Definition:
bloaty/third_party/re2/util/pod_array.h:19
re2::PODArray::data
T * data() const
Definition:
bloaty/third_party/re2/util/pod_array.h:24
re2
Definition:
bloaty/third_party/re2/re2/bitmap256.h:17
re2::PODArray::PODArray
PODArray(int len)
Definition:
bloaty/third_party/re2/util/pod_array.h:21
T
#define T(upbtypeconst, upbtype, ctype, default_value)
re2::PODArray::size
int size() const
Definition:
bloaty/third_party/re2/util/pod_array.h:28
re2::PODArray::operator[]
T & operator[](int pos) const
Definition:
bloaty/third_party/re2/util/pod_array.h:32
re2::PODArray::Deleter::operator()
void operator()(T *ptr) const
Definition:
bloaty/third_party/re2/util/pod_array.h:43
re2::PODArray::ptr_
std::unique_ptr< T[], Deleter > ptr_
Definition:
bloaty/third_party/re2/util/pod_array.h:50
re2::PODArray::Deleter::Deleter
Deleter()
Definition:
bloaty/third_party/re2/util/pod_array.h:38
re2::PODArray::Deleter::len_
int len_
Definition:
bloaty/third_party/re2/util/pod_array.h:47
value
const char * value
Definition:
hpack_parser_table.cc:165
std
Definition:
grpcpp/impl/codegen/async_unary_call.h:407
len
int len
Definition:
abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
re2::PODArray::Deleter::Deleter
Deleter(int len)
Definition:
bloaty/third_party/re2/util/pod_array.h:40
re2::PODArray
Definition:
bloaty/third_party/re2/util/pod_array.h:14
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:44