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.
std::vector<std::unique_ptr<T> > nixt::PtrPool< T >::Nodes |