Files
ladybird/Libraries/LibGC/HeapVector.h
Sam Atkins 8ffac507c6 LibGC: Include CellAllocator.h in HeapVector.h
Next commit adds a user of this which doesn't already have the
GC_DECLARE_ALLOCATOR() macro available.
2026-02-17 07:40:03 -05:00

40 lines
747 B
C++

/*
* Copyright (c) 2025, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGC/Cell.h>
#include <LibGC/CellAllocator.h>
namespace GC {
template<typename T>
class HeapVector : public Cell {
GC_CELL(HeapVector, Cell);
GC_DECLARE_ALLOCATOR(HeapVector);
public:
HeapVector() = default;
virtual ~HeapVector() override = default;
auto& elements() { return m_elements; }
auto const& elements() const { return m_elements; }
virtual void visit_edges(Visitor& visitor) override
{
Base::visit_edges(visitor);
visitor.visit(m_elements);
}
private:
Vector<T> m_elements;
};
template<typename T>
GC_DEFINE_ALLOCATOR(HeapVector<T>);
}