Friend function template with automatic return type deduction cannot access a private member
- 阅读更多 关于 Friend function template with automatic return type deduction cannot access a private member
问题 Sorry for how complicated the title of this question is; I tried to describe the minimal SSCCE I constructed for this problem. I have the following code: #include <iostream> namespace fizz { template<typename... Ts> class bar { public: template<int I, typename... Us> friend auto foo(const bar<Us...> &); private: int i = 123; }; template<int I, typename... Ts> auto foo(const bar<Ts...> & b) { return b.i; } } int main() { std::cout << fizz::foo<1>(fizz::bar<int, float>{}); } This code compiles