I want a class to create a using
alias from the return type of one of its base class' protected
member functions. However, the following fails:
#include <type_traits>
class B
{
protected:
int fun(){return 0;}
};
class D : protected B
{
using T = decltype(std::declval<B>().fun());
};
main() {}
prog.cpp:5:6: error: ‘int B::fun()’ is protected int fun(){return 0;}
Why doesn't D
have access to the protected method of its base?