title: Using reference_wrapper as condition_variable predicate
body: <p>Note: The following applies equally to Boost.Thread and C++11 threads.</p>
  
  <p>I have a condition variable which condition is actually a simple boolean variable.</p>
  
  <pre><code>// assume these are global
  mutex m;
  condition_variable c;
  boolean b = false;
  </code></pre>
  
  <p>I wanted to use the <code>wait(lock, predicate)</code> syntax. I could use for example a lambda:</p>
  
  <pre><code>c.wait(lock, [] () { return b; });
  </code></pre>
  
  <p>But I supposed there should be a more idiomatic way to wrap a variable as a callable. So I found out that <code>reference_wrapper</code> provides an <code>operator()</code> that retrieves the wrapped value. Therefore I tried:</p>
  
  <pre><code>c.wait(lock, cref(b));
  </code></pre>
  
  <p>But g++ (4.9.1) does not compile it, arguing <code>no matching function for call to '(boost::reference_wrapper&lt;const bool&gt;) ()'</code> (if I use <code>std::ref</code> the error is somewhat different, but still not compiling).</p>
  
  <p>Shouldn't a <code>reference_wrapper</code> qualify as a proper predicate for a condition variable? If not, why? And what would be the right wrapper for <code>b</code> in this case?</p>
  
  <p>EDIT: So @Praetorian has explained quite right my mistake, but, is there really nothing like this on Boost or the standard (there may be mistakes here):</p>
  
  <pre><code>template&lt;typename T&gt;
  struct as_callable {
      T &amp;objref;
      as_callable(T &amp;r) : objref(r) {}
      T &amp;operator()() {
          return objref;
      }
  };
  </code></pre>