From 4c285f9e1a76aee5de16deb256f939823f554bfc Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 28 Jun 2019 20:20:19 +0200 Subject: [PATCH] AK: Add Vector(std::initializer_list) constructor. This allows us to construct a Vector from an initializer list like so: Vector objects = { object1, object2, object3 }; --- AK/Vector.h | 8 ++++++++ Kernel/Makefile | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/AK/Vector.h b/AK/Vector.h index e639ba6c1e0..2ed2dc7bfc1 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -3,6 +3,7 @@ #include #include #include +#include #ifndef __serenity__ #include @@ -64,6 +65,13 @@ public: clear(); } + Vector(std::initializer_list 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) diff --git a/Kernel/Makefile b/Kernel/Makefile index 8579d3bf38b..cd90d8c48ae 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -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