mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-06 16:09:30 +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
|
@ -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…
Reference in a new issue