Skip to content

Commit 338bf32

Browse files
committed
Removed conditional code [skip ci]
1 parent 944bd65 commit 338bf32

File tree

6 files changed

+6
-42
lines changed

6 files changed

+6
-42
lines changed

include/pgvector/halfvec.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88

99
#include <cstddef>
1010
#include <ostream>
11+
#include <span>
1112
#include <utility>
1213
#include <vector>
1314

14-
#if __cplusplus >= 202002L
15-
#include <span>
16-
#endif
17-
1815
namespace pgvector {
1916
/// A half vector.
2017
class HalfVector {
@@ -42,13 +39,11 @@ class HalfVector {
4239
value_ = std::vector<float>{value, value + n};
4340
}
4441

45-
#if __cplusplus >= 202002L
4642
/// Creates a half vector from a span.
4743
// TODO add explicit in 0.3.0
4844
HalfVector(std::span<const float> value) {
4945
value_ = std::vector<float>(value.begin(), value.end());
5046
}
51-
#endif
5247

5348
/// Returns the number of dimensions.
5449
size_t dimensions() const {

include/pgvector/sparsevec.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@
99
#include <algorithm>
1010
#include <cstddef>
1111
#include <ostream>
12+
#include <span>
1213
#include <stdexcept>
1314
#include <unordered_map>
1415
#include <vector>
1516

16-
#if __cplusplus >= 202002L
17-
#include <span>
18-
#endif
19-
2017
namespace pgvector {
2118
/// A sparse vector.
2219
class SparseVector {
@@ -48,7 +45,6 @@ class SparseVector {
4845
}
4946
}
5047

51-
#if __cplusplus >= 202002L
5248
/// Creates a sparse vector from a span.
5349
// TODO add explicit in 0.3.0
5450
SparseVector(std::span<const float> value) {
@@ -61,7 +57,6 @@ class SparseVector {
6157
}
6258
}
6359
}
64-
#endif
6560

6661
/// Creates a sparse vector from a map of non-zero elements.
6762
SparseVector(const std::unordered_map<int, float>& map, int dimensions) {

include/pgvector/vector.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88

99
#include <cstddef>
1010
#include <ostream>
11+
#include <span>
1112
#include <utility>
1213
#include <vector>
1314

14-
#if __cplusplus >= 202002L
15-
#include <span>
16-
#endif
17-
1815
namespace pgvector {
1916
/// A vector.
2017
class Vector {
@@ -42,13 +39,11 @@ class Vector {
4239
value_ = std::vector<float>{value, value + n};
4340
}
4441

45-
#if __cplusplus >= 202002L
4642
/// Creates a vector from a span.
4743
// TODO add explicit in 0.3.0
4844
Vector(std::span<const float> value) {
4945
value_ = std::vector<float>(value.begin(), value.end());
5046
}
51-
#endif
5247

5348
/// Returns the number of dimensions.
5449
size_t dimensions() const {

test/halfvec_test.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
#include <cassert>
2+
#include <span>
23

34
#include <pgvector/halfvec.hpp>
45

5-
#if __cplusplus >= 202002L
6-
#include <span>
7-
#endif
8-
96
using pgvector::HalfVector;
107

118
static void test_constructor_vector() {
129
auto vec = HalfVector({1, 2, 3});
1310
assert(vec.dimensions() == 3);
1411
}
1512

16-
#if __cplusplus >= 202002L
1713
static void test_constructor_span() {
1814
auto vec = HalfVector(std::span<const float>({1, 2, 3}));
1915
assert(vec.dimensions() == 3);
2016
}
21-
#endif
2217

2318
void test_halfvec() {
2419
test_constructor_vector();
25-
#if __cplusplus >= 202002L
2620
test_constructor_span();
27-
#endif
2821
}

test/sparsevec_test.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
#include <cassert>
2+
#include <span>
23
#include <unordered_map>
34

45
#include <pgvector/sparsevec.hpp>
56

6-
#if __cplusplus >= 202002L
7-
#include <span>
8-
#endif
9-
107
using pgvector::SparseVector;
118

129
static void test_constructor_vector() {
@@ -16,12 +13,10 @@ static void test_constructor_vector() {
1613
assert(vec.values() == (std::vector<float>{1, 2, 3}));
1714
}
1815

19-
#if __cplusplus >= 202002L
2016
static void test_constructor_span() {
2117
auto vec = SparseVector(std::span<const float>({1, 0, 2, 0, 3, 0}));
2218
assert(vec.dimensions() == 6);
2319
}
24-
#endif
2520

2621
static void test_constructor_map() {
2722
std::unordered_map<int, float> map = {{2, 2}, {4, 3}, {3, 0}, {0, 1}};
@@ -33,8 +28,6 @@ static void test_constructor_map() {
3328

3429
void test_sparsevec() {
3530
test_constructor_vector();
36-
#if __cplusplus >= 202002L
3731
test_constructor_span();
38-
#endif
3932
test_constructor_map();
4033
}

test/vector_test.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
#include <cassert>
2+
#include <span>
23

34
#include <pgvector/vector.hpp>
45

5-
#if __cplusplus >= 202002L
6-
#include <span>
7-
#endif
8-
96
using pgvector::Vector;
107

118
static void test_constructor_vector() {
129
auto vec = Vector({1, 2, 3});
1310
assert(vec.dimensions() == 3);
1411
}
1512

16-
#if __cplusplus >= 202002L
1713
static void test_constructor_span() {
1814
auto vec = Vector(std::span<const float>({1, 2, 3}));
1915
assert(vec.dimensions() == 3);
2016
}
21-
#endif
2217

2318
void test_vector() {
2419
test_constructor_vector();
25-
#if __cplusplus >= 202002L
2620
test_constructor_span();
27-
#endif
2821
}

0 commit comments

Comments
 (0)