Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using reference member prevents defining assignment operator for the iterator class of int_vector_buffer #436

Open
cartoonist opened this issue Dec 8, 2020 · 0 comments · May be fixed by #437

Comments

@cartoonist
Copy link

The iterator type of int_vector_buffer has a non-static reference member to the container:

int_vector_buffer<t_width>& m_ivb;

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?

cartoonist added a commit to cartoonist/sdsl-lite that referenced this issue Dec 8, 2020
Using reference member prevents defining assignment operator for the
iterator class of int_vector_buffer. This commit fixes simongog#436.
jltsiren added a commit to vgteam/sdsl-lite that referenced this issue Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant