gpt4 book ai didi

c++ - QtConcurrent::run() 不能处理超过 5 个参数?

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:57:55 24 4
gpt4 key购买 nike

将具有 6 个或更多参数的函数传递给 QtConcurrent::run() 时出现编译错误。当我将它们减少到 5 个参数时,我不再收到此错误。

这个伪代码为我重现了错误:

void foo(int, int, int, int, int, int)
{

}

QtConcurrent::run(foo, 1, 2, 3, 4, 5, 6);

编译错误是:

error: no matching function for call to 'run(void (&)(int, int, int, int, int, int), int, int, int, int, int, int)'

应该是这样吗? QtConcurrent::run() 真的最多只能有 5 个参数吗?

最佳答案

参见qtconcurrentrun.h

template <typename T, typename Param1, typename Arg1, typename Param2, typename Arg2, typename Param3, typename Arg3, typename Param4, typename Arg4, typename Param5, typename Arg5>
QFuture<T> run(T (*functionPointer)(Param1, Param2, Param3, Param4, Param5), const Arg1 &arg1, const Arg2 &arg2, const Arg3 &arg3, const Arg4 &arg4, const Arg5 &arg5);

函数可以接受5个参数

关于c++ - QtConcurrent::run() 不能处理超过 5 个参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16917298/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com