我想通过std线程类将某些数据数组传递给函数。我得到错误与当前的方法参数,它采用C数组。超出C数组,向量或标准数组,这将是与std线程一起使用的最佳结构?我需要通过引用传递这些数组,并能够在函数完成后访问它们。与std线程,C数组,向量或std数组一起使用的最佳数组类型?
-5
A
回答
0
如果你知道在编译时的大小,然后用std::array
或std::vector::resize
一个std::vector
,否则只使用一个std::vector
。
真的不需要在C++中使用任何c风格,特别是在线程中,因为c函数不需要是线程安全的。
+0
我不知道在编译时的大小,那么这种情况下最好的方法是什么? – bakalolo
+0
@bukalolo然后使用std :: vectors。 –
相关问题
- 1. 复制数组到一个std ::向量
- 2. PHP将数组与std类组合
- 3. 的std ::数组
- 4. 使用std :: thread将多个线程的数组组合在一起使用std :: thread
- 5. 使用malloc/realloc为包含std向量的类/结构数组
- 6. std类对象数组
- 7. std :: unique_ptr与数组指针
- 8. 的std ::向量与指针静态数组与自定义类型
- 9. 删除STD数组::串与C++
- 10. 在一个数组上使用std :: sort()
- 11. void类型的std ::元组
- 12. 用std :: async编辑数组
- 13. std :: string的指针数组
- 14. 将c字符串数组复制到std :: string向量中
- 15. 使用std :: unique_ptr的双(二维)数组
- 16. C++ MPI:数组上的std :: merge
- 17. 从std类多维数组中提取完整的数组php
- 18. std ::未指定模板类的数组
- 19. std :: string与静态const的char数组
- 20. 使用数组或向量在Python中使用numpy向数组或向量填充数组没有循环
- 21. std :: vector与C++中的原始数组有多类似?
- 22. 如何将std :: basic_string类型转换为char类型的数组?
- 23. c + +让与的std ::向量或std一个banlist ::地图
- 24. 的std ::元组VS的std ::数组作为性病的项目::矢量
- 25. 从std :: wstring Asisgn LPCWSTR数组
- 26. Deduce std ::数组大小?
- 27. 从函数到“main”范围传递变量(数组类型)类型:std :: tr1 :: match_results <std :: string :: const_iterator>
- 28. 清除std :: vector数组的最佳方法?
- 29. 将变量数组转换为std :: tuple
- 30. std ::合并使用2个mmaped数组?
为什么不发布代码和错误,并寻求帮助,而不是主观的“最好的方式”来做到这一点? – NathanOliver
如果您的函数通过引用获取参数,'std :: thread'不会直观地表现出来。确保在必要时使用['std :: ref'](http://en.cppreference.com/w/cpp/utility/functional/ref),以确保引用实际上使用的参数。 –