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