【发布时间】:2011-01-27 02:51:59
【问题描述】:
我正在尝试编译这样的东西:
#include <list>
class thread
{
public:
static volatile std::list<thread *> threadList; //This is also protected by a mutex
};
volatile std::list<thread *> thread::threadList;
void main()
{
thread A;
thread::threadList.push_back(&A);
thread::threadList.remove(&A);
}
我在尝试编译时遇到这些错误:
test.cpp(14): error C2663: 'std::list::push_back' : 2 overloads have no legal conversion for 'this' pointer
with
[
_Ty=thread *
]
test.cpp(15): error C2662: 'std::list::remove' : cannot convert 'this' pointer from 'volatile std::list' to 'std::list &'
with
[
_Ty=thread *
]
Conversion loses qualifiers
我做错了什么?
编辑:用
修复了一些格式错误
EDIT2:threadList 受互斥体保护,为了简单起见,我没有把它放在这里
【问题讨论】:
-
我打赌他想要一份他拥有的所有 c++0x 或 boost
thread的列表,并且他希望拥有它们的容器能够同步
标签: c++