Can I pull all members of a private base into the public scope of an inheriting class?

65 Views Asked by At

When inheriting privately from a base class, I can say public: using Base::member; to make that (non-private) member public within the inheriting class. Is there some way to expand this to get all the members at once? The context I want this in is a CTRP setting I'm using to avoid code duplication.

Example:

struct Base {
  int foo();
  void bar();
  // ...
}

struct A : private Base {
  using Base::*; // not correct syntax

  // should have the effect of
  using Base::foo;
  using Base::bar;
  // ...
};

Even better would be if I could select only Base's public members, but not its protected or private members. This would just be a bonus.

0

There are 0 best solutions below