I'm getting this std::_Bit_const_iterator error when trying to find an element in a std::vector<bool> using std::find. Can somebody explain what is it that I'm doing wrong.
#include <iostream> #include <vector> #include <iterator> #include <algorithm> int32_t main(int32_t argc, char* argv[]) { std::vector<std::vector<bool>> bin_mat; bin_mat = { { true, false, false }, { false, false, true }, { true, false, false } }; for(const auto& row : bin_mat) { const std::vector<bool>::iterator row_itr = std::find(row.begin(), row.end(), true); std::size_t column_index = std::distance(row_itr, row.begin()); std::cout << column_index << std::endl; } return EXIT_SUCCESS; } This is the error I'm getting conversion from ‘std::_Bit_const_iterator’ to non-scalar type ‘const iterator {aka const std::_Bit_iterator}’ requested const std::vector<bool>::iterator row_itr = std::find(row.begin(), row.end(), true);
std::distanceis odd. I think you mean to swap the arguments.begintorow_itrnot the other way around.