21 #define ACTS_CHECK_BIT(value, mask) ((value & mask) == mask)
32 const std::vector<std::shared_ptr<T>>&
items) {
33 std::vector<T*> rawPtrs;
34 rawPtrs.reserve(
items.size());
35 for (
const std::shared_ptr<T>& item :
items) {
36 rawPtrs.push_back(item.get());
48 const std::vector<std::shared_ptr<const T>>&
items) {
49 std::vector<const T*> rawPtrs;
50 rawPtrs.reserve(
items.size());
51 for (
const std::shared_ptr<const T>& item :
items) {
52 rawPtrs.push_back(item.get());
64 const std::vector<std::shared_ptr<T>>&
items) {
65 std::vector<const T*> rawPtrs;
66 rawPtrs.reserve(
items.size());
67 for (
const std::shared_ptr<T>& item :
items) {
68 rawPtrs.push_back(item.get());
80 template <std::
size_t kDIM,
typename value_type>
81 std::array<value_type, kDIM>
to_array(
const std::vector<value_type>& vecvals) {
82 std::array<value_type, kDIM> rarray = {};
83 for (
const auto [iv,
v] :
enumerate(vecvals)) {
108 template <
template <
size_t>
class Callable,
size_t N,
size_t NMAX,
112 return Callable<N>::invoke(std::forward<Args>(
args)...);
115 std::cerr <<
"template_switch<Fn, " <<
N <<
", " <<
NMAX <<
">(v=" << v
116 <<
") is not valid (v == 0 and N != 0)" << std::endl;
119 if constexpr (
N <
NMAX) {
120 return template_switch<Callable, N + 1, NMAX>(
v,
121 std::forward<Args>(
args)...);
123 std::cerr <<
"template_switch<Fn, " <<
N <<
", " <<
NMAX <<
">(v=" << v
124 <<
") is not valid (v > NMAX)" << std::endl;
135 template <
size_t N,
size_t NMAX,
typename Lambda,
typename...
Args>
138 return func(std::integral_constant<size_t, N>{},
139 std::forward<Args>(
args)...);
142 std::cerr <<
"template_switch<Fn, " <<
N <<
", " <<
NMAX <<
">(v=" << v
143 <<
") is not valid (v == 0 and N != 0)" << std::endl;
146 if constexpr (
N <
NMAX) {
147 return template_switch_lambda<N + 1, NMAX>(
v, func,
148 std::forward<Args>(
args)...);
150 std::cerr <<
"template_switch<Fn, " <<
N <<
", " <<
NMAX <<
">(v=" << v
151 <<
") is not valid (v > NMAX)" << std::endl;
160 template <
typename T,
typename U>
162 return std::clamp(value, static_cast<U>(std::numeric_limits<T>::lowest()),
163 static_cast<U>(std::numeric_limits<T>::max()));
174 template <
typename T>
175 std::array<typename T::value_type, 2u>
min_max(
const T& tseries) {
176 return {*std::min_element(tseries.begin(), tseries.end()),
177 *std::max_element(tseries.begin(), tseries.end())};
187 template <
typename T>
188 std::tuple<typename T::value_type, ActsScalar>
range_medium(
const T& tseries) {
192 return std::tie(range, medium);