19#ifndef CPPREALM_BRIDGE_UTILS_HPP
20#define CPPREALM_BRIDGE_UTILS_HPP
40#if __has_include(<cpprealm/internal/bridge/bridge_types.hpp>)
41#include <cpprealm/internal/bridge/bridge_types.hpp>
44namespace realm::internal::bridge {
45 template <
typename Left,
typename Right,
typename =
void>
47 template <
typename Left,
typename Right>
48 struct LayoutCheck<Left, Right, std::enable_if_t<(sizeof(Left) == sizeof(Right) && alignof(Left) == alignof(Right))>> : std::true_type {
52namespace realm::internal {
53 template <
typename... Ts,
typename... Us,
size_t... Is>
54 auto constexpr zip_tuples_impl(
const std::tuple<Ts...>& tuple1,
const std::tuple<Us...>& tuple2, std::index_sequence<Is...>) {
55 return std::make_tuple(std::make_pair(std::get<Is>(tuple1), std::get<Is>(tuple2))...);
58 template <
typename... Ts,
typename... Us>
59 auto constexpr zip_tuples(
const std::tuple<Ts...>& tuple1,
const std::tuple<Us...>& tuple2) {
60 static_assert(
sizeof...(Ts) ==
sizeof...(Us),
"Tuples must have the same size");
61 return zip_tuples_impl(tuple1, tuple2, std::index_sequence_for<Ts...>());
64 template <
typename T, std::size_t N, std::size_t... Is>
65 auto constexpr array_to_tuple_impl(
const std::array<T, N>& arr, std::index_sequence<Is...>) {
66 return std::make_tuple(arr[Is]...);
69 template <
typename T, std::
size_t N>
70 auto constexpr array_to_tuple(
const std::array<T, N>& arr) {
71 return array_to_tuple_impl(arr, std::make_index_sequence<N>{});