title: Issue in predicate function in wait in thread C++
body: <p>I am trying to put the condition inside a function but it is throwing confusing compile time error . While if I write it in lambda function  like this []{ retur i == k;} it is showing k is unidentified . Can anybody tell How to solve this problem .</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;mutex&gt;
  #include &lt;sstream&gt;
  #include &lt;thread&gt;
  #include &lt;chrono&gt;
  #include &lt;condition_variable&gt;
  using namespace std;
  condition_variable cv;
  mutex m;
  int i;
  bool check_func(int i,int k)
  {
      return i == k;
  }
  void print(int k)
  {
     unique_lock&lt;mutex&gt; lk(m);
     cv.wait(lk,check_func(i,k));            // Line 33
     cout&lt;&lt;"Thread no. "&lt;&lt;this_thread::get_id()&lt;&lt;" parameter "&lt;&lt;k&lt;&lt;"\n";
     i++;
     return;
  }
  int main() 
  {
      thread threads[10];
      for(int i = 0; i &lt; 10; i++)
         threads[i] = thread(print,i);
      for(auto &amp;t : threads)
         t.join();
      return 0;
  }
  </code></pre>
  
  <h1>Compiler Error:</h1>
  
  <pre><code>In file included from 6:0:
  /usr/include/c++/4.9/condition_variable: In instantiation of 'void std::condition_variable::wait(std::unique_lock&lt;std::mutex&gt;&amp;, _Predicate) [with _Predicate = bool]':
  33:30:   required from here
  /usr/include/c++/4.9/condition_variable:97:14: error: '__p' cannot be used as a function
    while (!__p())
                ^
  </code></pre>