Skip to content

Commit 896ba22

Browse files
committed
Added std::span constructor to Vector
1 parent 16ee7a0 commit 896ba22

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.1 (unreleased)
2+
3+
- Added `std::span` constructor to `Vector`
4+
15
## 0.2.0 (2024-07-10)
26

37
- Added support for `halfvec` and `sparsevec` types

include/vector.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#include <ostream>
1010
#include <vector>
1111

12+
#if __cplusplus >= 202002L
13+
#include <span>
14+
#endif
15+
1216
namespace pgvector {
1317
class Vector {
1418
public:
@@ -26,6 +30,12 @@ class Vector {
2630
value_ = std::vector<float>{value, value + n};
2731
}
2832

33+
#if __cplusplus >= 202002L
34+
Vector(std::span<const float> value) {
35+
value_ = std::vector<float>(value.begin(), value.end());
36+
}
37+
#endif
38+
2939
size_t dimensions() const {
3040
return value_.size();
3141
}

0 commit comments

Comments
 (0)