like in the title, here is a pice of code:
class matrix{
std::vector<std::vector<bool>> base;
std::pair<int, int> size;
public:
matrix(int x, int y){
size.first = x; size.second = y;
std::vector<std::vector<bool>> b(x, std::vector<bool>(y));
base = b;
}
bool& operator ()(int x, int y) const {
if(x < 0 || y < 0 || x >= size.first || y >= size.second){outOfBounds ex; throw ex;}
return base[x][y];
}
/*and more that is unrelated to the question*/
};
the error is in bool& operator(...) and it is as follows:
cannot bind non-const lvalue reference of type ‘bool&’ to an rvalue of type‘std::vector<bool>::const_reference’ {aka ‘bool’}
30 | return base[x][y];
in the code, the size of the vector (matrix) dose not change
I also replaced bool with int and its the same problem, can't convert from int to int&
The function can't be const, so that the value of the reference can be changed