I'm using CRTP, and I have a problem with accessing the protected members of derived class.
Here is example, close to my code:
template< typename Self>
  class A {
  public:
      void foo( ) {
          Self s;
          s._method( s); //ERROR, because _method is protected
      }
  protected:
      virtual  void _method( const Self & b) = 0;
  };
class B : public A< B> {
protected:
    void _method( const B & b) {}
};
I understood, that I must use friend keyword. But I can't understand where to put it in class A< Self>. I know that I could make void _method( const B &b) public in B, but I don't want to do it. Using any keywords in B is impossible for me either!
                        
I just found the solution. Thanks for answers. I just need to change this line:
to
And it works! http://ideone.com/CjclqZ