1#ifndef TATOOINE_UTILITY_H
2#define TATOOINE_UTILITY_H
23template <
size_t Omit,
size_t... Is,
size_t... Js>
25 std::index_sequence<Js...>) {
26 std::array indices{Is...};
27 (++indices[Js + Omit], ...);
32template <
size_t N,
size_t Omit>
34 return sliced_indices<Omit>(std::make_index_sequence<N - 1>{},
35 std::make_index_sequence<N - Omit - 1>{});
38template <
typename F,
typename... Ts>
40 (f(std::forward<Ts>(ts)), ...);
48 const std::array<size_t, N>& max_chunk_resolution) {
49 auto partitions = make_array<std::vector<std::pair<size_t, size_t>>, N>();
50 for (
size_t j = 0; j < N; ++j) {
51 const auto num_partitions =
static_cast<size_t>(ceil(
52 static_cast<double>(resolution[j]) / (max_chunk_resolution[j] - 1)));
53 partitions[j] = std::vector<std::pair<size_t, size_t>>(
54 num_partitions, {0, max_chunk_resolution[j]});
55 for (
size_t i = 0; i < num_partitions; ++i) {
56 partitions[j][i].first = (max_chunk_resolution[j] - 1) * i;
58 partitions[j].back().second = resolution[j] - partitions[j].back().first;
82 T tmp = std::move(t0);
87template <
typename T,
typename Ret,
typename ... Args>
89template <
typename T,
typename Ret,
typename ... Args>
92template <
typename F,
typename... Args>
93auto repeat(
size_t const n, F&& f, Args&&... args) {
94 for (
size_t i = 0; i < n; ++i) {
95 f(std::forward<Args>(args)...);
100 if constexpr (std::is_rvalue_reference_v<
decltype(x)>) {
101 return std::forward<decltype(x)>(x);
103 return std::decay_t<
decltype(x)>{x};
Definition: algorithm.h:6
constexpr void tat_swap(T &t0, T &t1)
Definition: utility.h:81
auto repeat(size_t const n, F &&f, Args &&... args)
Definition: utility.h:93
auto partition_resolution(const std::array< size_t, N > &resolution, const std::array< size_t, N > &max_chunk_resolution)
Definition: utility.h:47
constexpr auto release_mode()
Definition: utility.h:72
typename internal_data_type< T >::type internal_data_type_t
Definition: utility.h:20
auto copy_or_keep_if_rvalue(auto &&x) -> decltype(auto)
Definition: utility.h:99
constexpr auto debug_mode()
Definition: utility.h:64
Ret(T::*)(Args...) const const_method_ptr
Definition: utility.h:88
constexpr void for_each(F &&f, Ts &&... ts)
Definition: utility.h:39
Ret(T::*)(Args...) non_const_method_ptr
Definition: utility.h:90
constexpr auto sliced_indices()
creates an index sequence and removes an element from it
Definition: utility.h:33
T type
Definition: utility.h:16