title: How do I check if a value is contained in a vector? C++
body: <p>I have a vector that I am trying to perform a contains function on. I am receiving some sort of casting error and I can't piece together a solution. I am also wanting to know whether or not what I am doing is the appropriate way to check if a vector contains a value.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;vector&gt;
  
  static void someFunc(double** Y, int length);
  static bool contains(double value, std::vector&lt;double&gt; vec);
  
  int main()
  {
      double doubleArray[] = { 1, 2, 3, 4, 5 };
      double *pDoubleArray = doubleArray;
      int size = sizeof doubleArray / sizeof doubleArray[0];
  
      someFunc(&amp;pDoubleArray, size);
  
      return 0;
  }
  static void someFunc(double** Y, int length)
  {   
      std::vector&lt;double&gt; vec();
  
      for(int i = 0; i &lt; 10; i++)
      {
          //error: 'contains' : cannot convert parameter 2 from 'std::vector&lt;_Ty&gt; (__cdecl *)(void)' to 'std::vector&lt;_Ty&gt;'
          if(contains(*(Y[i]), vec)) 
          {
              //do something
          }
      }
  
  }
  static bool contains(double value, std::vector&lt;double&gt; vec)
  {
      for(int i = 0; i &lt; vec.size(); i++)
      {
          if(vec[i] == value)
          {
              return true;
          }
      }
  
      return false;
  }
  </code></pre>