How to let C++ know that an operator has been overloaded for a class
<p>Is it possible to write a template function for which a particular type of classes have some functions or overloaded operators? For instance</p>

<pre><code>template &lt;typename T&gt;
void dosomething(const T&amp; x){
    std::cout &lt;&lt; x[0] &lt;&lt; std::endl;
}
</code></pre>

<p>In this context I'm assuming that x is a class that behaves like an array, that is, I have overloaded the <code>[]</code> operator as well as the <code>&lt;&lt;</code> so that it can work with <code>std::cout</code>. </p>

<p>The actual code that I have is slightly different but gcc is giving me</p>

<pre><code>error: subscripted value is neither array nor pointer
</code></pre>

<p>This must be because it doesn't know that I'm expecting <code>T</code> to be of some class that overloads the <code>[]</code> operator. Does anyone know if it is possible to overcome this? I'd like to let c++ know that the particular type <code>T</code> will have the <code>[]</code> overloaded. </p>
