title: C++ unexpected implict conversion
body: <p>The following code compiles due to the implicit conversion for <code>char</code>.  I'm not sure why since the only implicit conversion I would expect (and expect to fail) is from <code>char const*</code> to <code>size_t</code>.</p>
  
  <pre><code>#include &lt;cstddef&gt;
  
  struct foo
  {
      int operator[](size_t i) const { return 1; }
      operator char() const { return 'a'; }
  };
  
  int main()
  {
      foo f;
      f["hello"]; // compilation error desired here
  }
  </code></pre>
  
  <p>What is the implicit conversion here that allows this to compile?  If I remove <code>operator char</code> or make it <code>explicit</code> then the compile fails at the desired location.</p>
  
  <p>The class that this code is extracted from really does need both the implicit conversion and the <code>operator[]</code>.  So is there a way I can prevent the behaviour without making the conversion explicit?</p>