boost::thread::thread(<未解析的重载函数类型>, int) - 模板化类成员函数

boost::thread::thread(<unresolved overloaded function type>, int) - templated class member function

本文关键字:函数 thread int 成员 重载 lt 类型 boost gt      更新时间:2023-10-16

我在寻找任何技巧,如何使下面的代码工作,但我什么都找不到。所以我想知道这是否可能。。。

我需要在我的参数化类中运行一些线程。这是一个示例代码:

template<typename T, int SIZE, class ThreadingSettings, class CheckingPolicy>
class MyClass {
  void Run() { boost::thread testThread(WriteValueA, 5); }
  void WriteValueA(const T value) {/* some work here */}
}

但是g++错误:

boost::thread::thread(<unresolved overloaded function type>, int)

这就是我创建该类对象的方法:

typedef MyClass<int, 4, SingleThread, NoCheckingPolicy> int_class;
int_class a;

感谢您的帮助。

编辑:

我在Win7上使用带有cygwin的NetBeans。我包括以下文件:

#include <boost/thread.hpp>
#include <boost/date_time.hpp>
template<typename T, int SIZE, class ThreadingSettings, class CheckingPolicy>
class MyClass {
public:
  void Run() { boost::thread testThread(boost::ref(*this), 5); }
  void operator()(const T value) {/* some work here */}
};
相关文章: