4

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;}

Live example

Why doesn't D have access to the protected method of its base?

quant
  • 21,507
  • 32
  • 115
  • 211
  • 2
    http://stackoverflow.com/questions/16785069/why-cant-a-derived-class-call-protected-member-function-in-this-code – NPE Oct 03 '14 at 06:29

0 Answers0