title: How to use a class member variable in a unary predicate?
body: <p>Suppose I have the following code:</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;algorithm&gt;
  #include &lt;cmath&gt;
  
  bool pred(float const &amp;val)
  {
      //return fabs(val) &lt; epsilon;
  }
  
  class Foo
  {
  public:
      Foo(float eps) : epsilon(eps) { }
  
      int Bar(std::vector&lt;float&gt; vec)
      {
          return std::count_if(vec.begin(), vec.end(), pred);
      }
  private:
      float epsilon;
  }
  </code></pre>
  
  <p>I want to have the unary predicate <code>pred()</code> as a class method so that it can access the <code>epsilon</code> member variable. I've seen examples using the <code>operator()</code>, but if I got it right, the operator is supposed to compare the entire class instance. I only need to compare the given <code>std::vector</code>'s elements in <code>Bar()</code>. Is it possible to create an unary predicate as a class member? If not, is there any other way to do it?</p>