Consider the below code.
struct foo {
friend foo create(foo) { return {}; }
};
int main() {
auto a = create(foo{});
return 0;
}
This code compiles perfectly on all compilers.
But the next below code compiles only in MSVC.
struct foo {};
struct bar {
friend bar create(foo) { return {}; }
};
int main() {
auto a = create(foo{});
return 0;
}
Other compilers, such as gcc, clang fail to compile with the following error.
error: 'create' was not declared in this scope
9 | auto a = create(foo{});
Is this non-standard?
I'm working on some template thing, so I must declare the friend function inside of the bar
.
Is there any way to achieve it?