0

我刚刚开始与 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.0\VC\INCLUDE\memory(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 替换。

任何想法都将不胜感激!

问候奥克

4

1 回答 1

0

感谢迈克·西摩

source_node<std::shared_ptr<int>>(g,[&](std::shared_ptr<int> val) -> bool {val = std::make_shared<int>(0);return true;},false);
于 2015-05-20T09:35:34.853 回答