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

编程入门 行业动态 更新时间:2024-10-24 17:25:47
本文介绍了C++11 std::bind 和 boost::bind 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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

Is there any difference between the two? Or am I safe to replace every occurrence of boost::bind by std::bind in my code and thereby remove the dependence on Boost?

推荐答案

boost::bind 有重载关系运算符,std::bind 没有.

boost::bind 支持非默认调用约定,不保证std::bind(标准库实现可能会将此作为扩展提供).

boost::bind supports non-default calling conventions, std::bind is not guaranteed to (standard library implementations may offer this as an extension).

boost::bind 提供了一种直接机制,允许防止对嵌套绑定表达式(boost::protect), std::bind才不是.(也就是说,如果需要,可以将 boost::protectstd::bind 一起使用,或者自己简单地重新实现它.)

boost::bind provides a direct mechanism to allow one to prevent eager evaluation of nested bind expressions (boost::protect), std::bind does not. (That said, one can use boost::protect with std::bind if they want, or trivially reimplement it on their own.)

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

std::bind provides a direct mechanism to allow one to treat any user defined functor as a nested bind expression in order to force eager evaluation (std::is_bind_expression: [func.bind.isbind]/1, [func.bind.bind]/10), boost::bind does not.

这篇关于C++11 std::bind 和 boost::bind 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-01 08:59:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/826510.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区别   std   boost   bind

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!