tipc
A TIP to LLVM compiler
ASTinternal.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "ASTNode.h"
4 
5 #include <algorithm>
6 
15 template <typename T>
16 std::vector<T *> rawRefs(const std::vector<std::shared_ptr<T>> &v) {
17  std::vector<T *> r;
18 
19  /*
20  * This call passes an anonymous function, i.e., a lambda, that is
21  * applied to each element in the input vector. The result of that
22  * application is used to build up the output vector. If you haven't
23  * seen lambda's before in C++ they are denoted by the "[]" syntax.
24  */
25  std::transform(v.begin(), v.end(), std::back_inserter(r),
26  [](auto &up) { return up.get(); });
27  return r;
28 }
std::vector< T * > rawRefs(const std::vector< std::shared_ptr< T >> &v)
Definition: ASTinternal.h:16