title: Accessing the [] operator from a pointer
body: <p>If I define a pointer to an object that defines the <code>[]</code> operator, is there a direct way to access this operator from a pointer?</p>
  
  <p>For example, in the following code I can directly access <code>Vec</code>'s member functions (such as <code>empty()</code>) by using the pointer's <code>-&gt;</code> operator, but if I want to access the <code>[]</code> operator I need to first get a reference to the object and then call the operator.</p>
  
  <pre><code>#include &lt;vector&gt;
  
  int main(int argc, char *argv[])
  {
      std::vector&lt;int&gt; Vec(1,1);
      std::vector&lt;int&gt;* VecPtr = &amp;Vec;
  
  if(!VecPtr-&gt;empty())      // this is fine
      return (*VecPtr)[0]; // is there some sort of -&gt;[] operator I could use?
  
  return 0;
  }
  </code></pre>
  
  <p>I might very well be wrong, but it looks like doing <code>(*VecPtr).empty()</code> is less efficient than doing <code>VecPtr-&gt;empty()</code>. Which is why I was looking for an alternative to <code>(*VecPtr)[]</code>.</p>