gpt4 book ai didi

c++ - C++11 std::bind 和 boost::bind 的区别

转载 作者:IT老高 更新时间:2023-10-28 12:12:18 58 4
gpt4 key购买 nike

这两者有什么区别吗?或者我是否可以安全地将代码中每次出现的 boost::bind 替换为 std::bind 从而消除对 Boost 的依赖?

最佳答案

  • boost::bind has overloaded relational operators , std::bind 没有。

  • boost::bind supports non-default calling conventions , std::bind 不保证(标准库实现可能提供此作为扩展)。

  • boost::bind 提供了一种直接机制,允许人们防止对嵌套绑定(bind)表达式 (boost::protect)、std::bind 进行急切求值 没有。 (也就是说,如果他们愿意,可以将 boost::protectstd::bind 一起使用,或者自己简单地重新实现它。)

  • std::bind 提供了一种直接机制,允许将任何用户定义的仿函数视为嵌套的绑定(bind)表达式,以便强制急切求值(std::is_bind_expression : [func.bind.isbind]/1, [func.bind.bind]/10), boost::bind 没有。

关于c++ - C++11 std::bind 和 boost::bind 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10555566/

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