c++ 中的静态声明班级
我不明白为什么第一个不起作用而第二个起作用!
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include "concurrentQueue.h";
class TestClass {
public:
static concurrentQueue<function<void()>> notW;
static concurrentQueue<int> Works;
}
我还附上了并发队列类的开头:
template<class Data> class concurrentQueue
I don't understand why the first doesn't work instead the second works!
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include "concurrentQueue.h";
class TestClass {
public:
static concurrentQueue<function<void()>> notW;
static concurrentQueue<int> Works;
}
I attach also the beginning of the concurrentQueue class:
template<class Data> class concurrentQueue
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在
>>
内放置一个空格,以防止其被视为右移运算符:对于 C++11 编译器,这不是必需的,因为编译器将解释尖括号尽可能关闭模板参数列表。
Put a space inside the
>>
to prevent it from being treated as a right-shift operator:With C++11 compilers this won't be necessary, as the compiler will interpret the angle brackets as closing the template argument list where possible.
在 C++ 03 及更早版本中,两个右尖括号之间需要有一个空格。这已在 2011 年新标准中得到“修复”。
例如,请参阅此问题了解更多信息。
You need a space between the two closing angle brackets in C++ 03 and earlier. This has been "fixed" in the new 2011 standard.
See for example this question for more information.