Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
drop_keys.hpp
Go to the documentation of this file.
1#pragma once
2#include <tuple>
3
4#ifndef IPC_CODEGEN_MSGPACK_DROP_KEYS_DEFINED
5#define IPC_CODEGEN_MSGPACK_DROP_KEYS_DEFINED
6
7namespace msgpack {
8template <typename Tuple, std::size_t... Is> auto drop_keys_impl(Tuple&& tuple, std::index_sequence<Is...>)
9{
10 // Expand 0 to n/2 to 1 to n+1 (increments of 2)
11 // Use it to filter the tuple
12 return std::tie(std::get<Is * 2 + 1>(std::forward<Tuple>(tuple))...);
13}
14
18template <typename... Args> auto drop_keys(std::tuple<Args...>&& tuple)
19{
20 static_assert(sizeof...(Args) % 2 == 0, "Tuple must contain an even number of elements");
21 // Compile time sequence of integers from 0 to n/2
22 auto compile_time_0_to_n_div_2 = std::make_index_sequence<sizeof...(Args) / 2>{};
23 return drop_keys_impl(tuple, compile_time_0_to_n_div_2);
24}
25} // namespace msgpack
26
27#endif
auto drop_keys(std::tuple< Args... > &&tuple)
Drops every first value pairwise of a flat argument tuple, assuming that they are keys.
Definition drop_keys.hpp:18
auto drop_keys_impl(Tuple &&tuple, std::index_sequence< Is... >)
Definition drop_keys.hpp:8
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13