【问题标题】:solving issue # C++98 Valid use of “for_each” in the code using Boost library 1.53 or 1.56解决问题 # C++98 在使用 Boost 库 1.53 或 1.56 的代码中有效使用“for_each”
【发布时间】:2014-11-14 16:34:17
【问题描述】:

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

问题已经得到解答,这就是我在这里创建另一个问题的原因;只为好奇。 谢谢。

【问题讨论】:

标签: c++ boost boost-bind boost-foreach


【解决方案1】:

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

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-27
    • 2021-12-08
    相关资源
    最近更新 更多