title: Accessing member from a static function - std::foreach
body: <p>Is it possible to access a static member function through <code>std::for_each</code>?</p>
  
  <p>I've hit a problem with a class I'm trying to code. I have a class <code>Foo</code> which in the member section initialises an object of <code>Boo</code> and I need to access this inside of a static member function that is used in <code>std::foreach()</code> details below:</p>
  
  <p>Foo.h</p>
  
  <pre><code>class Foo {
     public: 
        Foo() {
  
            w = getInstanceOfAnotherClass(0, 0); // this works fine!
        }
        void Transform();
  
        static inline void processBlock(std::vector&lt;double&gt; &amp;vect);
  
     private: 
       std::vector&lt;std::vector&lt;double&gt; &gt; data;
       Boo* w;
  }; 
  </code></pre>
  
  <p>Here is the problem: Inside of the member function <code>Transform</code> I have the following:</p>
  
  <pre><code>void Foo::Transform() 
  {
      std::for_each(data.begin(), data.end(), processBlock);
  }
  </code></pre>
  
  <p>And in <code>ProcessBlock</code> I have the following:</p>
  
  <pre><code>void Foo::processBlock(std::vector&lt;double&gt; &amp;vect) 
  {
      std::vector&lt;double&gt; vars = w.getDataBack&lt;double&gt;(); 
  }
  </code></pre>
  
  <p>The error that is returned is that <code>w</code> invalid use of member 'w' in static member function, now, I know what the problem is.. But I don't know know of a workaround. I decided to create another function that wasn't static and then call this function from inside of <code>processBlock</code>, however, the member function cannot be called without declaring an object, which, would therefore re-set the value of <code>w</code> and this is not what I want.</p>
  
  <p>I hope someone can help and this post isn't confusing. </p>