Jamba C++ API
7.5.0
Loading...
Searching...
No Matches
stl.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2023 pongasoft
3
*
4
* Licensed under the Apache License, Version 2.0 or the MIT license,
5
* at your option. You may not use this file except in compliance with
6
* one of these licenses. You may obtain copies of the licenses at:
7
*
8
* https://www.apache.org/licenses/LICENSE-2.0
9
* https://opensource.org/licenses/MIT
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
* License for the specific language governing permissions and limitations under
15
* the License.
16
*
17
* @author Yan Pujante
18
*/
19
20
#ifndef PONGASOFT_JAMBA_STL_H
21
#define PONGASOFT_JAMBA_STL_H
22
23
#include <array>
24
25
namespace
pongasoft::stl
{
26
27
// Implementation
28
namespace
impl
{
29
template
<
typename
T,
typename
U,
typename
F, std::size_t N, std::size_t... I>
30
constexpr
std::array<U, N>
transformArray
(std::array<T, N>
const
&a, F &&f, std::index_sequence<I...>)
31
{
32
return
{ f(a[I])... };
33
}
34
35
}
36
40
template
<
typename
T,
typename
U,
typename
F, std::
size_t
N,
typename
Indices = std::make_index_sequence<N>>
41
constexpr
std::array<U, N>
transform
(std::array<T, N>
const
&a, F &&f)
42
{
43
return
impl::transformArray<T, U>
(a, std::forward<F>(f), Indices{});
44
}
45
46
}
47
48
#endif
//PONGASOFT_JAMBA_STL_H
pongasoft::stl::impl
Definition
stl.h:28
pongasoft::stl::impl::transformArray
constexpr std::array< U, N > transformArray(std::array< T, N > const &a, F &&f, std::index_sequence< I... >)
Definition
stl.h:30
pongasoft::stl
Definition
stl.h:25
pongasoft::stl::transform
constexpr std::array< U, N > transform(std::array< T, N > const &a, F &&f)
Transforms an array containing elements of type T into an array containing elements of type U by appl...
Definition
stl.h:41
pongasoft
Utils
stl.h
Generated by
1.16.1