negative_index_semantics.cpp
Go to the documentation of this file.
1
#include "
negative_index_semantics.h
"
2
3
#include <algorithm>
4
5
6
size_t
armarx::armem::base::detail::negativeIndexSemantics
(
long
index
,
size_t
size)
7
{
8
const
size_t
max
= size > 0 ? size - 1 : 0;
9
if
(
index
>= 0)
10
{
11
return
std::clamp<size_t>(
static_cast<
size_t
>
(
index
), 0,
max
);
12
}
13
else
14
{
15
return
static_cast<
size_t
>
(std::clamp<long>(
static_cast<
long
>
(size) +
index
, 0,
static_cast<
long
>
(
max
)));
16
}
17
}
index
uint8_t index
Definition:
EtherCATFrame.h:59
armarx::armem::base::detail::negativeIndexSemantics
size_t negativeIndexSemantics(long index, size_t size)
Definition:
negative_index_semantics.cpp:6
max
T max(T t1, T t2)
Definition:
gdiam.h:48
negative_index_semantics.h
RobotAPI
libraries
armem
core
base
detail
negative_index_semantics.cpp
Generated on Sat Oct 12 2024 09:14:08 for armarx_documentation by
1.8.17