aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2021-03-01 07:46:18 +0000
committerArne Juul <arnej@verizonmedia.com>2021-03-01 10:26:38 +0000
commitce1619525f84a92d19a204b14c3974dcc018109d (patch)
tree894d9a88d0c3592ce35c815f3d2f23aa0916ae28 /vespalib
parent27d1885ca7ed987a9190343ec2eb45c11eb1aa48 (diff)
add constructors from SmallVector
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/arrayref.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/util/arrayref.h b/vespalib/src/vespa/vespalib/util/arrayref.h
index 03634a7a094..2433f9251cf 100644
--- a/vespalib/src/vespa/vespalib/util/arrayref.h
+++ b/vespalib/src/vespa/vespalib/util/arrayref.h
@@ -2,6 +2,7 @@
#pragma once
#include "array.h"
+#include "small_vector.h"
#include <vector>
namespace vespalib {
@@ -17,6 +18,8 @@ public:
ArrayRef(T * v, size_t sz) noexcept : _v(v), _sz(sz) { }
template<typename A=std::allocator<T>>
ArrayRef(std::vector<T, A> & v) noexcept : _v(&v[0]), _sz(v.size()) { }
+ template<size_t N>
+ ArrayRef(SmallVector<T, N> &v) noexcept : _v(&v[0]), _sz(v.size()) { }
ArrayRef(Array<T> &v) noexcept : _v(&v[0]), _sz(v.size()) { }
T & operator [] (size_t i) { return _v[i]; }
const T & operator [] (size_t i) const { return _v[i]; }
@@ -35,6 +38,8 @@ public:
ConstArrayRef(const T *v, size_t sz) noexcept : _v(v), _sz(sz) { }
template<typename A=std::allocator<T>>
ConstArrayRef(const std::vector<T, A> & v) noexcept : _v(&v[0]), _sz(v.size()) { }
+ template<size_t N>
+ ConstArrayRef(const SmallVector<T, N> &v) noexcept : _v(&v[0]), _sz(v.size()) { }
ConstArrayRef(const ArrayRef<T> & v) noexcept : _v(&v[0]), _sz(v.size()) { }
ConstArrayRef(const Array<T> &v) noexcept : _v(&v[0]), _sz(v.size()) { }
ConstArrayRef() noexcept : _v(nullptr), _sz(0) {}