Skip to content

Commit 4b3c87a

Browse files
committed
Added static casts [skip ci]
1 parent ec2fb0c commit 4b3c87a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
3232
add_executable(test test/halfvec_test.cpp test/main.cpp test/pqxx_test.cpp test/sparsevec_test.cpp test/vector_test.cpp)
3333
target_link_libraries(test PRIVATE libpqxx::pqxx pgvector::pgvector)
3434
if(NOT MSVC)
35-
target_compile_options(test PRIVATE -Wall -Wextra -Wpedantic -Werror)
35+
target_compile_options(test PRIVATE -Wall -Wextra -Wpedantic -Wconversion -Werror)
3636
endif()
3737
endif()
3838
endif()

include/pgvector/sparsevec.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ class SparseVector {
3333

3434
/// Creates a sparse vector from a span.
3535
explicit SparseVector(std::span<const float> value) {
36-
dimensions_ = value.size();
36+
// TODO throw exception
37+
dimensions_ = static_cast<int>(value.size());
3738
for (size_t i = 0; i < value.size(); i++) {
3839
float v = value[i];
3940
if (v != 0) {
40-
indices_.push_back(i);
41+
indices_.push_back(static_cast<int>(i));
4142
values_.push_back(v);
4243
}
4344
}

0 commit comments

Comments
 (0)