vecmem
1.18.0
Loading...
Searching...
No Matches
core
include
vecmem
utils
impl
memmove.ipp
1
/* VecMem project, part of the ACTS project (R&D line)
2
*
3
* (c) 2025 CERN for the benefit of the ACTS project
4
*
5
* Mozilla Public License Version 2.0
6
*/
7
#pragma once
8
9
namespace
vecmem
{
10
namespace
details {
11
12
VECMEM_HOST_AND_DEVICE
13
inline
void
memmove
(
void
*
dest
,
const
void
*
src
, std::size_t
bytes
) {
14
15
// Check for some trivial cases.
16
if
((
dest
==
src
) || (
bytes
== 0)) {
17
return
;
18
}
19
20
// Cast the char pointers.
21
char
*
dest_char
=
static_cast<
char
*
>
(
dest
);
22
const
char
*
src_char
=
static_cast<
const
char
*
>
(
src
);
23
24
if
((
dest_char
<
src_char
) || (
dest_char
>= (
src_char
+
bytes
))) {
25
// Non-overlapping, or overlapping such that a forward copy does the
26
// correct thing.
27
for
(std::size_t
i
= 0;
i
<
bytes
; ++
i
) {
28
dest_char
[
i
] =
src_char
[
i
];
29
}
30
}
else
{
31
// Overlapping such that a backward copy would do the correct thing.
32
for
(std::size_t
i
=
bytes
;
i
> 0; --
i
) {
33
dest_char
[
i
- 1] =
src_char
[
i
- 1];
34
}
35
}
36
}
37
38
}
// namespace details
39
}
// namespace vecmem
vecmem::allocator
An allocator class that wraps a memory resource.
Definition
allocator.hpp:37
vecmem::details::memmove
VECMEM_HOST_AND_DEVICE void memmove(void *dest, const void *src, std::size_t bytes)
Hand-written implementation of a memmove function.
Definition
memmove.ipp:13
vecmem
Main namespace for the vecmem classes/functions.
Definition
atomic_ref.hpp:16
Generated by
1.9.8