Performance hit from using std::find : <p>I have the following code to check whether a value belongs to a list of values. eg: <code>contains({1,2,3},3)</code>. Almost always, I could write a bunch of <code>if-else</code>s. How much performance hit does the <code>contains</code> approach create? Is there a way to avoid this?</p>

<pre><code>template&lt;typename T1,typename T2&gt;
std::enable_if_t&lt;std::is_same&lt;std::initializer_list&lt;T2&gt;,T1&gt;::value, bool&gt; contains(const T1 &amp;container,const T2 &amp;item)
{
    return(std::find(container.begin(),container.end(),item)!=container.end());
}
</code></pre>
