使用std::shared_ptr线程化构建块
Threading Building Blocks using std::shared_ptr
我刚开始和TBB合作。不得不说它看起来很好,但我遇到了以下问题。在std::shared_ptr中使用lambda似乎不起作用。
source_node<int>(g,[&](int& val) -> bool {val = 0; return true;},false);
source_node<std::shared_ptr<int>(g,[&](std::shared_ptr<int> val) -> bool {val = std::make_shared<int>(0);return true;},false);
有以下编译错误:
error: C2665: 'std::shared_ptr<int>::shared_ptr' : none of the 5 overloads could convert all the argument types
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDEmemory(504): could be 'std::shared_ptr<int>::shared_ptr<main::<lambda_484cee4d4b0231890bebaeba94e0ddad>,bool>(std::nullptr_t,_Dx,_Alloc)'
with
[
_Dx=main::<lambda_484cee4d4b0231890bebaeba94e0ddad>
]
基本上int已经被std::shared_ptr取代了。
任何想法都将受到赞赏!
问候奥
谢谢Mike Seymour
source_node<std::shared_ptr<int>>(g,[&](std::shared_ptr<int> val) -> bool {val = std::make_shared<int>(0);return true;},false);
相关文章:
- 使用 task_group 的英特尔线程构建模块性能不佳(新用户)
- 什么是运行英特尔线程构建模块的 XCode 8 环境变量
- 使用英特尔线程构建块编译:错误操作数为?:
- 构建线程的幕后花絮
- 使用C 构建器在窗户上拍摄屏幕截图的线程安全
- 构建和同步多线程游戏循环
- 支持多线程方法来构建数组中所有元素的集合吗
- 从命令行构建x64 C++项目说:此操作应该只在UI线程上进行
- 使用boost线程1.51的程序没有't构建
- 在C++类中构建互斥保护的线程安全方法
- 如何为IOCP构建工作线程逻辑
- 线程池与英特尔线程构建模块一起使用
- 在 Linux 中构建 C++11 个可线程翻译单元
- 有没有办法控制英特尔线程构建模块中的线程数量、亲和力和创建时间
- Qt 在构建移动到线程的 QObject 时将"this"作为父传递
- 英特尔线程构建模块替代方案和许可
- 线程构建块流图 — 制作"counting"节点
- 使用Visual studio构建FLTK多线程(MT)项目
- 线程构建块parallel_sort
- 构建线程增强库