如何QtConcurrent::mapped
将成员函数用作运算符?目前我正在使用一个可调用对象(这是一个丑陋的解决方案):
struct Vectorizer {
Vectorizer(DialogCreateSamples* cs)
: m_createSamples(cs) { }
typedef QString result_type;
QString operator()(const QString &input)
{
return m_createSamples->generateVector(input);
}
DialogCreateSamples* m_createSamples;
};
QFuture<QString> future = QtConcurrent::mapped(m_inputs,Vectorizer(this));
还尝试传递 lambda 表达式,但编译器说result_type
lambda 中没有定义。这适用于QtConcurrent::map
因为map
不需要result_type
. 所以如果我可以typedef
在 lambda 中添加一个它应该可以工作......