tr1::result_of 的良好用例是什么?
我听说 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
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.
没有简单的案例。 但是,它用在
BOOST_AUTO
中,可以用于例如There are no simple cases. However, it's used in
BOOST_AUTO
, which can be used, e.g., in在进行元编程时它很有用。 我唯一一次使用它是在包装函数中。 如果 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.