gpt4 book ai didi

c++ - 解决问题 # C++98 在使用 Boost 库 1.53 或 1.56 的代码中有效使用 “for_each”

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:42:04 25 4
gpt4 key购买 nike

我已经问过了。我想知道 this 是否有任何解决方案 使用 boost::for_each 和 boost::bind。

这个问题已经回答过了,所以我在这里创建了另一个问题;只是为了好奇。谢谢。

最佳答案

是的,您可以使用 boost::bind 创建一个合适的仿函数,并为仿函数的参数设置一个占位符:

for_each(oldpnTs.begin(), oldpnTs.end(), bind(typeDetection, _1, ALL, *this));

在现代 C++ 中,我更喜欢新式循环

for (pnt & p : oldpnTs) {
typeDetection(p, ALL, *this);
}

关于c++ - 解决问题 # C++98 在使用 Boost 库 1.53 或 1.56 的代码中有效使用 “for_each”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26934672/

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