From 24ca5623e8187c3f71353bfe8c2e458b0a164414 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 29 Jul 2021 20:29:49 -0500 Subject: [PATCH] [ox/std] Add initializer_list constructor to Vector --- deps/ox/src/ox/std/vector.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/deps/ox/src/ox/std/vector.hpp b/deps/ox/src/ox/std/vector.hpp index 60f475c8..31415acd 100644 --- a/deps/ox/src/ox/std/vector.hpp +++ b/deps/ox/src/ox/std/vector.hpp @@ -8,6 +8,10 @@ #pragma once +#if __has_include() +#include +#endif + #include "bit.hpp" #include "iterator.hpp" #include "math.hpp" @@ -186,6 +190,10 @@ class Vector: detail::SmallVector { explicit Vector(std::size_t size) noexcept; + #if __has_include() + Vector(std::initializer_list list) noexcept; + #endif + Vector(const Vector &other); Vector(Vector &&other) noexcept; @@ -304,6 +312,15 @@ Vector::Vector(std::size_t size) noexcept { } } +#if __has_include() +template +Vector::Vector(std::initializer_list list) noexcept { + for (auto &item : list) { + emplace_back(item); + } +} +#endif + template Vector::Vector(const Vector &other) { m_size = other.m_size;