WARPXM v1.10.0
Loading...
Searching...
No Matches
meta.h
Go to the documentation of this file.
1#ifndef WXM_META_H
2#define WXM_META_H
3
4#include <vector>
5#include <algorithm>
6
10
11namespace wxm
12{
13namespace meta
14{
15
19template<bool... Vals> struct all
20{
21 constexpr static bool value = true;
22};
23
24template<bool... Vals> struct all<false, Vals...>
25{
26 constexpr static bool value = false;
27};
28
29template<bool... Vals> struct all<true, Vals...>
30{
31 constexpr static bool value = all<Vals...>::value;
32};
33
37template<typename T>
38std::vector<T> apply_permutation(std::vector<T>&& vec, const std::vector<std::size_t>& p)
39{
40 std::vector<T> sorted_vec(vec.size());
41 std::transform(p.begin(), p.end(), sorted_vec.begin(), [&](std::size_t i) {
42 return std::move(vec[i]);
43 });
44 return sorted_vec;
45}
46} // namespace meta
47} // namespace wxm
48
49#endif
std::vector< T > apply_permutation(std::vector< T > &&vec, const std::vector< std::size_t > &p)
Applies an order permutation (not in place?) to a vector.
Definition: meta.h:38
Base namespace for everything not included in the global namespace.
Definition: field_source.h:8
Determines if all predicated values are true or not.
Definition: meta.h:20
static constexpr bool value
Definition: meta.h:21