title: How to avoid implicit conversions from integer 0 to pointer, as the element of a vector
body: <p>There is a situation where I want to collect all the nodes names of a path to one key in JSON. Consider the condition: JSON array index &quot;0&quot;, &quot;1&quot; are also allowed, but it is easy to forget the quotes, which would lead to a crash when doing dereference. So I want compiler to reject this kind of parameters. Example:</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;vector&gt;
  #include &lt;iostream&gt;
  
  int func(const std::vector&lt;const char*&gt;&amp; pin) {
      return pin.size();
  }
  
  int main() {
      // {&quot;aname&quot;, &quot;3&quot;, &quot;path&quot;, &quot;0&quot;} wanted but this still compile
      std::cout &lt;&lt; func({&quot;aname&quot;, &quot;3&quot;, &quot;path&quot;, 0}) &lt;&lt; std::endl;
  }
  </code></pre>
  <p>Refering to <a href="https://stackoverflow.com/questions/12877546/how-do-i-avoid-implicit-conversions-on-non-constructing-functions">How do I avoid implicit conversions on non-constructing functions?</a> I tried something as following:</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;vector&gt;
  #include &lt;iostream&gt;
  
  // I want to describe only char pointer parameter is allowed as element,
  // parameter of any integer types should be rejected.
  int func(const std::vector&lt;const char*&gt;&amp; pin) {
      return pin.size();
  }
  
  int func(const std::vector&lt;int&gt;&amp; pin) = delete;
  // or
  template&lt;typename T&gt;
  int func(const std::vector&lt;T&gt;&amp; pin) = delete;
  
  int main() {
      std::cout &lt;&lt; func({&quot;aname&quot;, &quot;3&quot;, &quot;path&quot;, 0}) &lt;&lt; std::endl;
  }
  </code></pre>
  <p>But the compiler still can not understand me.<br />
  Any suggestion?</p>
  <p>Please point out any misuse of terminologies and assumptions, thank you!</p>