I tried declaring it outside the class by creating a inner
template<typename V, typename W> friend inner<V> get(outer<W>&);
You need to declare a template function before declaring a friend to tell the compiler what the get
function template is. eg.
template <typename T>
struct outer {
template <typename U>
class inner;
};
template <typename V, typename W>
typename outer<W>::template inner<V> get(outer<W>&);
template <typename T>
template <typename U>
class outer<T>::inner {
inner() {}
public:
friend inner<U> get<U>(outer<T>&);
};
template <typename V, typename W>
typename outer<W>::template inner<V> get(outer<W>&) {
return {};
}
Live
source
share