How to make a parent's template method visible from a child class?

Viewed 320

Here is a sample code:

#include <memory>

class A {
  public:
    template <class T> void f(std::unique_ptr<T>, int) {}

  private:
    virtual void f(int) = 0;
};

class B: public A {
  public:
    using A::f;

  private:
    virtual void f(int) override {}
};

int main() {
  std::unique_ptr<float> a;
  B* b = new B;
  b->f(std::move(a), 1);

  return 0;
}

When I compile it with clang++, I get an error:

'f' is a private member of 'A'
using A::f;
         ^

How to make the template method f(std::unique_ptr<T>, int) visible from class B?


Note: if the virtual method A::f(int) is moved to a public section - everything works fine.

2 Answers
Related