title: C++ Array Subscript Operator Template
body: <p>After trying to make access to a storage class a little easier, I ended up in a situation that I don't have a lot of knowledge on. And, finding people that are trying to do the same thing as me isn't easy.</p>
  
  <p>What I'm trying to do, is have a class that stores an array of values as strings internally, but allows simple type casting from the user's end. What I had planned on doing is use the array subscript operator to return whichever type they specify through a template. Although, it sounds a lot better than it works in practice. Here's a simple example of what I'm doing, to give you an idea of how it <em>should</em> work.</p>
  
  <pre><code>class StringList
  {
      public:
      template &lt;typename T&gt; 
      T operator[](const int i)
  }
  </code></pre>
  
  <p>From there, I would define a few specific templates, and any user could very easily define more if needed. But, the biggest problem with this is, I don't know how to call the subscript operator with a template. At first I assumed the following(which apparently isn't correct), considering it's similar to the standard way of calling a template method.</p>
  
  <pre><code>StringList list;
  T var = list&lt;T&gt;[0];
  </code></pre>
  
  <p>Does anyone know the proper way of calling the subscript operator as a template? Or, should I just avoid doing this, and use a named method?</p>