Browse Source

emplace back to vector

cbor
Ludovic 'Archivist' Lagouardette 4 years ago
parent
commit
1e121613cc
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      include/gp/vector.hpp

+ 10
- 0
include/gp/vector.hpp View File

@ -178,6 +178,16 @@ namespace gp{
return false; return false;
} }
template<typename ...U>
constexpr bool emplace_back(U&&... value) {
if(grow()) {
new(ary+sz) T(gp::forward<U>(value)...);
sz++;
return true;
}
return false;
}
constexpr gp::optional<T> pop_back() { constexpr gp::optional<T> pop_back() {
if(sz == 0) return gp::nullopt; if(sz == 0) return gp::nullopt;
sz--; sz--;

Loading…
Cancel
Save