Skip to content

Commit

Permalink
add tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
SachiSakurane committed Dec 26, 2024
1 parent 3b87cb9 commit 84da4b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/riw/tuple.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#include <riw/tuple/tuple_pair.hpp>
20 changes: 20 additions & 0 deletions include/riw/tuple/tuple_pair.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include <tuple>
#include <utility>

namespace riw {
namespace detail {
template <class... Ts, class... Us, std::size_t... Is>
constexpr inline auto tuple_pair_impl(const std::tuple<Ts...> &t1, const std::tuple<Us...> &t2,
std::index_sequence<Is...>) {
return std::make_tuple(std::make_pair(std::get<Is>(t1), std::get<Is>(t2))...);
}
} // namespace detail

template <class... Ts, class... Us>
constexpr inline auto tuple_pair(const std::tuple<Ts...> &t1, const std::tuple<Us...> &t2) {
static_assert(sizeof...(Ts) == sizeof...(Us), "Tuples must have the same number of elements");
return detail::tuple_pair_impl(t1, t2, std::index_sequence_for<Ts...>{});
}
} // namespace riw

0 comments on commit 84da4b5

Please sign in to comment.