[英]How to use range-v3's ranges::actions::transform?
I want to use ranges-v3
to transform an array in place.我想使用
ranges-v3
来转换一个数组。 I can use ranges::transform
successfully, but failed to use actions::transform
.我可以成功使用
ranges::transform
,但无法使用actions::transform
。
int arr[]{1, 2, 3};
auto fn = [](auto e) { return e + 1; };
ranges::transform(arr, std::begin(arr), fn); // ok
arr |= actions::transform(std::begin(arr), fn); // error
Error Message:错误信息:
fatal error: no matching function for call to object of type 'const ranges::actions::transform_fn'
arg |= actions::transform(std::begin(arr), std::begin(arr),
^~~~~~~~~~~~~~~~~~
How to use actions::transform
in such a case?在这种情况下如何使用
actions::transform
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.