title: Is there a way how to identify class of overloaded operator[] in c++?
body: <p>Let say we have a class with an operator [] as follows</p>
  <pre><code>class MyClass
  {
  //...
  public:
      TYPE operator[](const size_t idx) const
      {
          //... Implementation
      }
  }
  </code></pre>
  <p>Now i want to read <code>TYPE</code> and use it as a template argument for another class. One may use a trick</p>
  <pre><code>template&lt;class T&gt;
  class OtherClass
  {
      //...
  }
  
  template&lt;class T&gt;
  auto generator(const T&amp; element)
  {
      return OtherClass&lt;T&gt;(); 
  } 
  
  int main(void)
  {
      MyClass myclass;
      auto resulted_class = generator(myclass[0]);
      return 0;
  }
  </code></pre>
  <p>This should create an <code>OtherClass</code> with template <code>TYPE</code> from <code>MyClass</code> and copy it into <code>resulted_class</code>.</p>
  <p>And now the question. Is it possible to achieve the same but without generic call of [] operator for index value 0 or any specific index value? The point is that it is not guaranteed that operator [] is defined for a specific value. We just need to extract <code>TYPE</code> if possible.</p>
  <p>In other words, if we use a class like <code>std::vector&lt;double&gt;</code> we want to extract that <code>double</code> from that class. But without further knowledge about <code>std::vector</code>. The only thing we know is that there is a definition of [] operator within.</p>