summaryrefslogtreecommitdiff
path: root/utils/small_vector.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/small_vector.h')
-rw-r--r--utils/small_vector.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/utils/small_vector.h b/utils/small_vector.h
index 25c52359..ae1e5727 100644
--- a/utils/small_vector.h
+++ b/utils/small_vector.h
@@ -14,6 +14,7 @@
#include <stdint.h>
#include <new>
#include <stdint.h>
+#include "swap_pod.h"
//sizeof(T)/sizeof(T*)>1?sizeof(T)/sizeof(T*):1
template <class T,int SV_MAX=2>
@@ -245,6 +246,10 @@ public:
return !(a==b);
}
+ void swap(Self& o) const {
+ swap_pod(*this,o);
+ }
+
private:
union StorageType {
T vals[SV_MAX];
@@ -255,6 +260,11 @@ public:
uint16_t capacity_; // only defined when size_ > __SV_MAX_STATIC
};
+template <class T,int SV_MAX>
+inline void swap(SmallVector<T,SV_MAX> &a,SmallVector<T,SV_MAX> &b) {
+ a.swap(b);
+}
+
typedef SmallVector<int,2> SmallVectorInt;
template <class T,int N>