1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-30 15:48:00 +02:00
nix/src/libexpr/gc-small-vector.hh
Eelco Dolstra b9f78abb7f Alias traceable_allocator to std::allocator when building without GC
This allows us to get rid of a bunch of #ifdefs.
2024-09-19 21:04:01 +02:00

29 lines
702 B
C++

#pragma once
#include <boost/container/small_vector.hpp>
#include "value.hh"
namespace nix {
/**
* A GC compatible vector that may used a reserved portion of `nItems` on the stack instead of allocating on the heap.
*/
template <typename T, size_t nItems>
using SmallVector = boost::container::small_vector<T, nItems, traceable_allocator<T>>;
/**
* A vector of value pointers. See `SmallVector`.
*/
template <size_t nItems>
using SmallValueVector = SmallVector<Value *, nItems>;
/**
* A vector of values that must not be referenced after the vector is destroyed.
*
* See also `SmallValueVector`.
*/
template <size_t nItems>
using SmallTemporaryValueVector = SmallVector<Value, nItems>;
}