nixd
|
A simple pointer pool, a vector of unique_ptr
s.
More...
#include <PtrPool.h>
Public Member Functions | |
template<class U > | |
U * | add (std::unique_ptr< U > Node) |
Takes ownership of a node, add it to the pool. | |
template<class U > | |
U * | record (U *Node) |
Takes ownership from a raw pointer. | |
Public Attributes | |
std::vector< std::unique_ptr< T > > | Nodes |
A simple pointer pool, a vector of unique_ptr
s.
It is used for "owning" nodes. Other classes can use weak/raw pointers to the nodes, to avoid cyclic references.
Also in nix AST, the nodes are not owned by it's parent because in bison algorithm nodes should be copyable while performing shift-reduce. So in our implementation nodes are owned in this structure.
|
inline |
Takes ownership of a node, add it to the pool.
Definition at line 26 of file PtrPool.h.
References nixt::PtrPool< T >::Nodes.
Takes ownership from a raw pointer.
Definition at line 35 of file PtrPool.h.
References nixt::PtrPool< T >::Nodes.
std::vector<std::unique_ptr<T> > nixt::PtrPool< T >::Nodes |
Definition at line 23 of file PtrPool.h.
Referenced by nixt::PtrPool< T >::add(), and nixt::PtrPool< T >::record().