Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
map.hpp
Go to the documentation of this file.
1#pragma once
2#include <algorithm>
3#include <array>
4#include <type_traits>
5
6namespace bb::transform {
7/*
8 * Generic map function for mapping a containers element to another type.
9 */
10template <template <typename, typename...> typename Cont,
11 typename InElem,
12 typename... Args,
13 typename F,
14 typename OutElem = typename std::invoke_result<F, InElem const&>::type>
15Cont<OutElem> map(Cont<InElem, Args...> const& in, F&& op)
16{
17 Cont<OutElem> result;
18 std::transform(in.begin(), in.end(), std::back_inserter(result), op);
19 return result;
20}
21
22/*
23 * Generic map function for mapping a std::array's elements to another type.
24 */
25template <std::size_t SIZE,
26 typename InElem,
27 typename F,
28 typename OutElem = typename std::invoke_result<F, InElem const&>::type>
30{
32 std::transform(in.begin(), in.end(), result.begin(), op);
33 return result;
34}
35} // namespace bb::transform
Cont< OutElem > map(Cont< InElem, Args... > const &in, F &&op)
Definition map.hpp:15
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
VectorField result