template <typename T>
class A;
template <class T>
class A
{
template<typename U>
friend A<U> f(A<U> a);
};
template <class T>
A<T> f(A<T> a)
{
return A<T>();
}
int main()
{
A<int> a, b;
b = f(a);
return 0;
}
dGVtcGxhdGUgPHR5cGVuYW1lIFQ+CmNsYXNzIEE7CgoKdGVtcGxhdGUgPGNsYXNzIFQ+CmNsYXNzIEEKewogICB0ZW1wbGF0ZTx0eXBlbmFtZSBVPgkKICAgZnJpZW5kIEE8VT4gZihBPFU+IGEpOwp9OwoKdGVtcGxhdGUgPGNsYXNzIFQ+CkE8VD4gZihBPFQ+IGEpCnsKCXJldHVybiBBPFQ+KCk7Cn0KCgppbnQgbWFpbigpCnsKCiAgIEE8aW50PiBhLCBiOwogICBiID0gZihhKTsKCiAgIHJldHVybiAwOwp9