Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
make_vector_with_moved_list.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
6namespace fang::stl
7{
25 template<typename T,typename ... C >
26 std::vector<T> makeVectorWithMovedList(C ... movedElement)
27 {
28 std::vector<T> vector{};
29
30 // Ahh lambda function
31 // Arcane fold expression magick
32
33 // So a fold expression can cary out an operation on a pack
34 // Like in math when you say 1 + 2+ ... + n
35 // In this case, the lambda expression is called a lot
36 // every time lambda ... lambda ... lambda ...
37 // I tried refactoring the labmda out but it triggered some errors
38 // so I kept it the way the post said to do.
39 // the version with for-each did not work either.
40 // I try to minimize odd shenanigans like this, but this greatly
41 // benefits the code as we have a decent amount of variants which
42 // need a vector of unique_ptr items.
43 ([&]{vector.push_back(std::move(movedElement));}, ...);
44 return vector;
45 }
46}
Definition make_vector_with_moved_list.hpp:7
std::vector< T > makeVectorWithMovedList(C ... movedElement)
Definition make_vector_with_moved_list.hpp:26