Consider this code:
struct A
{
template <typename T>
using type = decltype(&T::foo);
};
class B
{
void foo() {}
friend A;
};
int main()
{
A::type<B> x;
}
It compiles on GCC and MSVC, but makes Clang complain: error: 'foo' is a private member of 'B'
.
Is it a Clang bug? How can I work around this issue?
Edit: The duplicate doesn't provide a workaround, so here's one.
struct A
{
template <typename T>
static decltype(&T::foo) helper();
template <typename T>
using type = decltype(helper<T>());
};
class B
{
void foo() {}
friend A;
};
int main()
{
A::type<B> x;
}