From 7eb81936e277f0c7bb171fddf3632896144e3ac7 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 9 Mar 2020 13:14:39 +0100 Subject: [PATCH] containers: add insert_at() utility function. --- include/lol/private/base/containers.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/lol/private/base/containers.h b/include/lol/private/base/containers.h index adf6bfa7..04390d29 100644 --- a/include/lol/private/base/containers.h +++ b/include/lol/private/base/containers.h @@ -51,6 +51,12 @@ static inline std::vector keys(T const &m) return ret; } +template +static inline auto insert_at(std::vector &v, size_t i, T const &x) +{ + return v.insert(v.begin() + i, x); +} + template static inline auto remove_at(std::vector &v, size_t i) {