我需要实现以下接口
struct mutex;
struct interface
{
//...
mutex& getMutex();
};
我的直觉告诉我可以在我的实现中使用 using mutex = ParticularMutex
,但gcc告诉我不行:
直觉告诉我可以使用 using mutex = ParticularMutex
在我的实现中,但是gcc告诉我不能:
error: conflicting declaration ‘using mutex = ’
error: ‘class mutex’ has a previous declaration as ‘class mutex’
我并没有两次定义任何东西,只是像前向声明时一样声明了两次,所以
- 为什么这不起作用?
- 是否有一种方法可以解决问题而不修改
interface
? - 应该如何定义
interface
?使用template <typename mutex>
吗?