diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-05-07 01:41:31 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-05-07 01:41:31 +0100 |
commit | 9ab2aad4aa00afe3373b3a779377fa049459fb4d (patch) | |
tree | 18bf013e3be660b0769cd1a601e670eb79355324 /lib/pack.h | |
parent | Rename strings.h to something that won't conflict with a system header (diff) | |
parent | Templated BufferedLocation and single buffer storage for RVC locations (diff) | |
download | ilt-9ab2aad4aa00afe3373b3a779377fa049459fb4d.tar.bz2 ilt-9ab2aad4aa00afe3373b3a779377fa049459fb4d.tar.xz ilt-9ab2aad4aa00afe3373b3a779377fa049459fb4d.zip |
Merge branch 'containers'
Diffstat (limited to 'lib/pack.h')
-rw-r--r-- | lib/pack.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/pack.h b/lib/pack.h new file mode 100644 index 0000000..e63d7cc --- /dev/null +++ b/lib/pack.h @@ -0,0 +1,41 @@ +#pragma once + +#include <utility> + +template<typename T, template<typename... S> typename Container> class pack : protected Container<T> { +public: + using Container<T>::Container; + + using Container<T>::begin; + using Container<T>::end; + using Container<T>::rbegin; + using Container<T>::rend; + using Container<T>::cbegin; + using Container<T>::cend; + using Container<T>::crbegin; + using Container<T>::crend; + using Container<T>::clear; + using Container<T>::empty; + using Container<T>::size; + using Container<T>::capacity; + using Container<T>::shrink_to_fit; + using Container<T>::at; + using Container<T>::data; + using Container<T>::operator[]; + + template<typename... Ps> + decltype(auto) + emplace(Ps &&... ps) + { + return Container<T>::emplace_back(std::forward<Ps>(ps)...); + } + + void + erase(typename Container<T>::iterator pos) + { + if (&*pos != &Container<T>::back()) { + *pos = std::move(Container<T>::back()); + } + Container<T>::pop_back(); + } +}; |