В классе B используется шаблон, который является частным членом класса A.
Я пытался объявить друга, но шаблон все еще закрыт в контексте.
Как разрешить B использовать закрытый шаблон A?
Тест (также на godbolt.org ):
#include <iostream>
#include <vector>
template <class T>
class A {
private:
template<typename R> using V = std::vector<R>;
};
template <typename T, class Prev>
class B {
public:
friend Prev;
typename Prev::template V<T> v_;
};
int main() {
B<int, A<int>> b;
return 0;
}
Ошибка компиляции:
error: ‘template<class R> using V
= std::vector<R, std::allocator<_CharT> >’
is private within this context
typename Prev::template V<T> v_;
^~