boost::thread::thread(<未解析的重载函数类型>, int) - 模板化类成员函数
boost::thread::thread(<unresolved overloaded function type>, int) - templated class member function
我在寻找任何技巧,如何使下面的代码工作,但我什么都找不到。所以我想知道这是否可能。。。
我需要在我的参数化类中运行一些线程。这是一个示例代码:
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 */}
};
相关文章:
- 对带有唯一指针的 std::thread 使用类成员函数时出现编译错误
- 将模板(没有规范)传递给 std::thread() 会出现错误:<未解析的重载函数类型>匹配错误
- 在没有复制构造函数的对象的成员函数中启动 std::thread
- 无法将参数传递给 boost::thread 构造函数
- CLang:在 std::thread 中运行函数会导致结构创建BAD_ACCESS
- 如何在 UWP C++/CX 中对象的成员函数中使用 std::thread
- 使用 std::thread & std::bind 在成员函数中启动线程
- 错误:调用 std::thread 没有匹配函数
- 有什么理由C++ 11+ std::mutex 应该声明为全局变量,而不是作为函数参数传递到 std::thread 中
- std::thread从函数启动,无需等待线程完成
- 使用 boost::thread 运行函子,但析构函数被错误地调用
- 睡眠影响 std::thread 调用哪个虚拟成员函数?
- 如何在不接触函数本身的情况下暂停和恢复 C++11 std::thread 的功能
- C++ - 在 std::thread 中调用重载函数时编译失败
- 子类化 std::thread:构造器中可变参数模板函数的问题
- 如果容器不是调用函数中的引用,则使用 std::thread 传递对迭代器的引用将失败
- 标准库中是否有与 std::thread 的构造函数语义匹配的类型擦除函数包装器?
- 将回调函数中对对象的引用传递给 std::thread
- thread.detach() 函数的左值何时会超出以下代码的范围
- VSCod 中的C++:错误:没有用于初始化'std::thread'的匹配构造函数