sdsl-lite
sdsl-lite copied to clipboard
Using reference member prevents defining assignment operator for the iterator class of int_vector_buffer
The iterator type of int_vector_buffer
has a non-static reference member to the container:
https://github.com/simongog/sdsl-lite/blob/c32874cb2d8524119f25f3b501526fe692df29f4/include/sdsl/int_vector_buffer.hpp#L492
This prevents creating default assignment operator. For example, compiling this snippet
sdsl::int_vector_buffer< 32 > entries;
// populate the integer vector
std::binary_search(entries.begin(), entries.end(), value);
fails using gcc 8.3:
/usr/include/c++/8/bits/stl_algobase.h:961:16: error: use of deleted function ‘sdsl::int_vector_buffer<32>::iterator& sdsl::int_vector_buffer<32>::iterator::operator=(const sdsl::int_vector_buffer<32>::iterator&)’
__first = __middle;
~~~~~~~~^~~~~~~~~~
In file included from /usr/local/include/sdsl/int_vector.hpp:1599,
from /usr/local/include/sdsl/bit_vectors.hpp:8,
from /home/cartoonist/workspace/psi/include/psi/crs_matrix.hpp:26,
from /home/cartoonist/workspace/psi/test/src/test_crsmatrix.cpp:18:
/usr/local/include/sdsl/int_vector_buffer.hpp:490:15: note: ‘sdsl::int_vector_buffer<32>::iterator& sdsl::int_vector_buffer<32>::iterator::operator=(const sdsl::int_vector_buffer<32>::iterator&)’ is implicitly deleted because the default definition would be ill-formed:
class iterator: public std::iterator<std::random_access_iterator_tag, value_type, difference_type, value_type*, reference>
^~~~~~~~
/usr/local/include/sdsl/int_vector_buffer.hpp:490:15: error: non-static reference member ‘sdsl::int_vector_buffer<32>& sdsl::int_vector_buffer<32>::iterator::m_ivb’, can’t use default assignment operator
make[2]: *** [test/CMakeFiles/psi-tests.dir/build.make:63: test/CMakeFiles/psi-tests.dir/src/test_crsmatrix.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:291: test/CMakeFiles/psi-tests.dir/all] Error 2
make: *** [Makefile:141: all] Error 2
Using pointer instead of reference to the container may solve the problem unless assignment operators are intentionally deleted. Is this the case?