mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
AK: Add Vector(std::initializer_list<T>) constructor.
This allows us to construct a Vector from an initializer list like so: Vector<Object> objects = { object1, object2, object3 };
This commit is contained in:
parent
933cd3848f
commit
4c285f9e1a
Notes:
sideshowbarker
2024-07-19 13:27:45 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/4c285f9e1a7
2 changed files with 9 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
|||
#include <AK/Assertions.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/kmalloc.h>
|
||||
#include <initializer_list>
|
||||
|
||||
#ifndef __serenity__
|
||||
#include <new>
|
||||
|
@ -64,6 +65,13 @@ public:
|
|||
clear();
|
||||
}
|
||||
|
||||
Vector(std::initializer_list<T> list)
|
||||
{
|
||||
ensure_capacity(list.size());
|
||||
for (auto& item : list)
|
||||
unchecked_append(item);
|
||||
}
|
||||
|
||||
Vector(Vector&& other)
|
||||
: m_size(other.m_size)
|
||||
, m_capacity(other.m_capacity)
|
||||
|
|
|
@ -92,7 +92,7 @@ OBJS = $(CXX_OBJS) Boot/boot.ao
|
|||
|
||||
KERNEL = kernel
|
||||
CXXFLAGS += -ffreestanding -mregparm=3 -mno-80387 -mno-mmx -mno-sse -mno-sse2
|
||||
CXXFLAGS += -nostdinc++ -nostdlib -nostdinc
|
||||
CXXFLAGS += -nostdlib
|
||||
DEFINES += -DKERNEL
|
||||
LDFLAGS += -Ttext 0x10000 -Wl,-T linker.ld -nostdlib
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue