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
4namespace msgpack {
5template <typename Tuple, std::size_t... Is> auto drop_keys_impl(Tuple&& tuple, std::index_sequence<Is...>)
6{
7 // Expand 0 to n/2 to 1 to n+1 (increments of 2)
8 // Use it to filter the tuple
9 return std::tie(std::get<Is * 2 + 1>(std::forward<Tuple>(tuple))...);
10}
11
15template <typename... Args> auto drop_keys(std::tuple<Args...>&& tuple)
16{
17 static_assert(sizeof...(Args) % 2 == 0, "Tuple must contain an even number of elements");
18 // Compile time sequence of integers from 0 to n/2
19 auto compile_time_0_to_n_div_2 = std::make_index_sequence<sizeof...(Args) / 2>{};
20 return drop_keys_impl(tuple, compile_time_0_to_n_div_2);
21}
22} // namespace msgpack
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:15
auto drop_keys_impl(Tuple &&tuple, std::index_sequence< Is... >)
Definition drop_keys.hpp:5
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13