boost::bind with protected members & context

前端 未结 3 586
不知归路
不知归路 2020-12-17 01:29

In the below code, there are two \"equivalent\" calls to std::for_each using boost:bind expressions. The indicated line compiles, the indicated fai

3条回答
  •  遥遥无期
    2020-12-17 01:58

    It's all about "context". In the first call the context of the call is Derived which has access to the protected members of Base and hence is allowed to take addresses of them. In the second the context is "outside of" Derived and hence outside of Base so the protected member access is not allowed.

提交回复
热议问题