Here's the code:
namespace Namespace
{
struct L0
{
enum SomeEnum
{
EnumVal
};
struct L1
{
friend void f(SomeEnum)
{
std::cout << "f()" << std::endl;
}
};
friend void g(SomeEnum)
{
std::cout << "g()" << std::endl;
}
};
}
int main()
{
f(Namespace::L0::EnumVal); // error: f not defined
g(Namespace::L0::EnumVal); // good
}
The idea here is to make the compiler find f() and g() through ADL.
However, this code fails to compile with gcc or clang. The similar code seemed to compile fine under MSVC though.
Maybe I miss something, but I don't really understand what is wrong with the code, and whether it is wrong at all. Would be nice if someone could shed some light on this one.
PS. Happy new year:)