title: Why is it not possible to use private method in a lambda?
body: <p>Having a class like this:</p>
  
  <pre><code>class A {
  public:
      bool hasGrandChild() const;
  
  private:
      bool hasChild() const;
      vector&lt;A&gt; children_;
  };
  </code></pre>
  
  <p>Why is it not possible to use a private method <code>hasChild()</code> in a lambda expression defined in the method <code>hasGrandChild()</code> like this?</p>
  
  <pre><code>bool A::hasGrandChild() const {
      return any_of(children_.begin(), children_.end(), [](A const &amp;a) {
          return a.hasChild();
      });
  }
  </code></pre>
  
  <p>Compiler issues an error that the method <code>hasChild()</code> is private within the context. Is there any workaround?</p>
  
  <p><strong>Edit:</strong>
  It seems that the code as I posted it originally works. I thought that it is equivalent, but the code that <a href="http://ideone.com/zKUsF" rel="noreferrer">does not work on GCC</a> is more like this:</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;algorithm&gt;
  
  class Foo;
  
  class BaseA {
  protected:
      bool hasChild() const { return !children_.empty(); }
      std::vector&lt;Foo&gt; children_;
  };
  
  class BaseB {
  protected:
      bool hasChild() const { return false; }
  };
  
  class Foo : public BaseA, public BaseB {
  public:
    bool hasGrandChild() const {
      return std::any_of(children_.begin(), children_.end(), [](Foo const &amp;foo) {
          return foo.BaseA::hasChild();
        });
    }  
  };
  
  int main()
  {
    Foo foo;
    foo.hasGrandChild();
    return 0;
  }
  </code></pre>
  
  <p>Seems that there is a problem with fully qualified names as <a href="http://ideone.com/DJezf" rel="noreferrer">this does not work</a>, but <a href="http://ideone.com/zGtYI" rel="noreferrer">this works</a>.</p>