From 1e121613cc101400f983299421108366276bb2eb Mon Sep 17 00:00:00 2001 From: Ludovic 'Archivist' Lagouardette Date: Tue, 6 Oct 2020 14:55:48 +0200 Subject: [PATCH] emplace back to vector --- include/gp/vector.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/gp/vector.hpp b/include/gp/vector.hpp index 05e9d27..4cb8663 100644 --- a/include/gp/vector.hpp +++ b/include/gp/vector.hpp @@ -178,6 +178,16 @@ namespace gp{ return false; } + template + constexpr bool emplace_back(U&&... value) { + if(grow()) { + new(ary+sz) T(gp::forward(value)...); + sz++; + return true; + } + return false; + } + constexpr gp::optional pop_back() { if(sz == 0) return gp::nullopt; sz--;