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
6
namespace
bb::transform
{
7
/*
8
* Generic map function for mapping a containers element to another type.
9
*/
10
template
<
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>
15
Cont<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
*/
25
template
<
std::size_t
SIZE,
26
typename
InElem,
27
typename
F,
28
typename
OutElem =
typename
std::invoke_result<F, InElem const&>::type>
29
std::array<OutElem, SIZE>
map
(
std::array<InElem, SIZE>
const
& in, F&& op)
30
{
31
std::array<OutElem, SIZE>
result
;
32
std::transform(in.begin(), in.end(),
result
.begin(), op);
33
return
result
;
34
}
35
}
// namespace bb::transform
bb::transform
Definition
map.hpp:6
bb::transform::map
Cont< OutElem > map(Cont< InElem, Args... > const &in, F &&op)
Definition
map.hpp:15
std::get
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition
tuple.hpp:13
result
VectorField result
Definition
vector_field_mont_mul_body.inl.hpp:14
src
barretenberg
common
map.hpp
Generated by
1.9.8