本文介绍了我什么时候应该关注std :: iostream :: sentry?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在线参考文献对 std :: iostream :: sentry 的目的有相当简短和模糊的描述。我什么时候应该关心这个小动物?

Online references have rather brief and vague descriptions on the purpose of std::iostream::sentry. When should I concern myself with this little critter? If it's only intended to be used internally, why make it public?

推荐答案

大多数人都不会写任何需要处理的代码与创建哨兵对象。当/如果您从流对象本身的流缓冲区中提取数据(或将其插入),则需要一个sentry对象。

Most people will never write any code that needs to deal with creating sentry objects. A sentry object is needed when/if you extract data from (or insert it into) the stream buffer that underlies the stream object itself.

只要您的插入/提取操作员使用其他iostream成员/操作符来完成其工作,它不必处理创建哨兵对象(因为那些其他iostream操作符将根据需要创建和销毁哨兵对象)。

As long as your insertion/extraction operator uses other iostream members/operators to do its work, it does not have to deal with creating a sentry object (because those other iostream operators will create and destroy sentry objects as needed).

这篇关于我什么时候应该关注std :: iostream :: sentry?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 04:04