【发布时间】:2013-03-01 23:22:17
【问题描述】:
我想知道g++ 的libstdc++ 中的__cerb 是什么意思,我发现这似乎是官方C++ 标准文档中命名的cerberos 的简称。
§ 22.3.1 / 3:
[ 示例:iostream
operator<<可能实现为:template <class charT, class traits> basic_ostream<charT,traits>& operator<< (basic_ostream<charT,traits>& s, Date d) { // !!!!!!!!!! typename basic_ostream<charT,traits>::sentry cerberos(s); // <--- !! HERE !! // !!!!!!!!!! if (cerberos) { ios_base::iostate err = ios_base::iostate::goodbit; tm tmbuf; d.extract(tmbuf); use_facet<time_put<charT,ostreambuf_iterator<charT,traits> > >( s.getloc()).put(s, s, s.fill(), err, &tmbuf, ’x’); s.setstate(err); // might throw } return s; }—结束示例]
为什么将 iostream sentry 对象称为 cerberos,cerberos 究竟是什么意思?
【问题讨论】:
-
所以只是守卫的通用名称?为什么 cerber o s?
-
使用这个名字的人一定非常高兴。
标签: c++ iostream naming naming-conventions