这是我的代码段
template <class T>
struct ClassFriendMaker
{
typedef T Type;
};
template <class T>
class Singleton
{
friend class ClassFriendMaker<T>::Type; // Problem in this line
//Other declaration
}
使用CLANG编译时,它给了我一个错误:
error: elaborated type refers to a typedef
friend class ClassFriendMaker<T>::Type;
^
我可能知道出了什么问题吗?三江源
答案 0 :(得分:1)
将类替换为朋友声明中的 typename
friend class ClassFriendMaker<T>::Type;
friend typename ClassFriendMaker<T>::Type;