tr1::result_of 的良好用例是什么?

发布于 2024-07-07 06:52:14 字数 84 浏览 7 评论 0原文

我听说 tr1::result_of 在 Boost 内部经常使用...我想知道 tr1::result_of 是否有任何好的(简单)用例可以在家里使用。

I hear that tr1::result_of gets used frequently inside of Boost... I'm wondering if there are any good (simple) use cases for tr1::result_of I can use at home.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

腻橙味 2024-07-14 06:52:14

result_of 的描述位于 open_std.org 。 Microsoft 有一个使用 result_of 的单元测试包装器的简单示例。

A description of result_of is given at open_std.org. Microsoft has a quick example of a unit test wrapper that uses result_of.

开始看清了 2024-07-14 06:52:14

没有简单的案例。 但是,它用在 BOOST_AUTO 中,可以用于例如

BOOST_AUTO(x, make_pair(a, b));

There are no simple cases. However, it's used in BOOST_AUTO, which can be used, e.g., in

BOOST_AUTO(x, make_pair(a, b));
烟花易冷人易散 2024-07-14 06:52:14

在进行元编程时它很有用。 我唯一一次使用它是在包装函数中。 如果 result_of::type 为 void,则包装器不返回任何内容。 否则它返回包装函数返回的任何内容。

It's useful when doing meta-programming. The only time I used it was in a wrapper function. If result_of<T>::type was void, the wrapper returned nothing. Otherwise it returns the whatever the wrapped function returns.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文