您现在的位置是:首页 > 电脑 > 

为什么iostream哨兵对象在标准中被称为“cerberos”?(Why are iostream sentry objects called “cerberos” in the standard?)

2025-07-16 16:54:04
为什么iostream哨兵对象在标准中被称为“cerberos”?(Why are iostream sentry objects called “cerberos” in the standard?) 我想知道__cerb在g++的libstdc++的含义,我发现这似乎是官方C ++标准文档中命名的cerberos的简称。 §22..1 / :
为什么iostream哨兵对象在标准中被称为“cerberos”?(Why are iostream sentry objects called “cerberos” in the standard?)

我想知道__cerb在g++的libstdc++的含义,我发现这似乎是官方C ++标准文档中命名的cerberos的简称。

§22..1 / :

[示例: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; (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究竟意味着什么?

I was wondering what __cerb means in the libstdc++ of g++, and I found out that this seems to be a short name for cerberos as named in the official C++ standard document.

§ 22..1 / :

[ Example: An iostream operator<< might be implemented as:

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; (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; }

— end example ]

Why are iostream sentry objects called cerberos, and what does cerberos actually mean?

最满意答案

塞伯鲁斯是三头狗1 ,守护着地狱的大门 ,让那些被困在内部的人避开冥河。 无论是谁写的那部分都喜欢希腊和/或罗马神话,并决定它将是一个适用于当地可变哨兵的名称。

至于为什么它以os结尾,可以想象三种情况:

他们完全忘记了希腊和拉丁名词衰落的规则,并认为它是如何拼写的 我完全忘记了希腊和拉丁名词衰落的规则,并指出了一个非问题。 他们将Cerberus和Kerberos的拼写混为一谈,让Cerberos成为希腊和罗马血统的基础哨兵。

显然,Cerberus的头部数量是可变的。 也许这更好地表达为“头狗,其中大于或等于1”。

Cerberus was the three headed dog1 who guarded the gates of hell, keeping those trapped within from crossing back over the river Styx. Whomever wrote that section fancied Greek and/or Roman mythology and decided it would be an applicable name for a local variable sentry.

As to why it ends in os, one can imagine three scenarios:

They completely forgot the rules for Greek and Latin noun declinati and thought that was how it is spelled I completely forgot the rules for Greek and Latin noun declinati and am pointing out a non-issue. They conflated the spellings of Cerberus and Kerberos, giving birth to Cerberos the basic_stream sentry of Greek and Roman descent.

1. Apparently the number of heads on Cerberus is variable. Perhaps this is better expressed as the "-headed dog, where is greater than or equal to 1."

#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格

本文地址:http://www.dnpztj.cn/diannao/70458.html

相关标签:无
上传时间: 2023-04-24 14:55:43
留言与评论(共有 6 条评论)
本站网友 北苑家园租房
12分钟前 发表
本站网友 降香的功效与作用
19分钟前 发表
让Cerberos成为希腊和罗马血统的基础哨兵
本站网友 白花蛇舌草
19分钟前 发表
Date d) { // !!!!!!!!!! typename basic_ostream<charT
本站网友 东圃租房
26分钟前 发表
本站网友 广州取消限价
27分钟前 发表
where is greater than or equal to 1."