问题描述
由于没有理由使用的,没有人把它们放在code目前正在写的?是否有遗留code,不论数量多少尚在包含它们的维护?
Given that there were once reasons to use digraphs and trigraphs in C and C++, does anyone put them in code being written today? Is there any substantial amount of legacy code still under maintenance that contains them?
(注:这里的有向图做的不可以的意思是有向图双方的和有多重含义,但这里的用途就像<$序列C $ C> ?? = 或&LT;
站在像#
和 [
)
(Note: Here, "digraph" does not mean "directed graph." Both digraph and trigraph have multiple meanings, but the intended use here are sequences like ??=
or <:
to stand in for characters like #
and [
)
推荐答案
有一个的(下一个标准之后,C ++ 1Y将被标准化为-hopefully- C ++ 14),其目的是去除的三字母标准。他们做了一个案例研究上的秘密,否则大codeBase的:
There is a proposal pending for C++1z (the next standard after C++1y will be standardized into -hopefully- C++14) that aims to remove trigraphs from the Standard. They did a case study on an otherwise undisclosed large codebase:
案例研究
三字符样构建于一体的大型codeBase包括用途是
检查。我们发现:
The uses of trigraph-like constructs in one large codebase were examined. We discovered:
的实例923逃脱?在一个字符串,以避免三字母
更换:字符串模式()const的{返回富 - ???? \\ - 的 - ?????? }
923 instances of an escaped ? in a string literal to avoid trigraph replacement: string pattern() const { return "foo-????\?-of-?????"; }
4三字母的情况下被有意使用测试code:两个
测试套件编译器,在一个测试套件为其他两个领域
Boost的preprocessor库。
4 instances of trigraphs being used deliberately in test code: two in the test suite for a compiler, the other two in a test suite for boost's preprocessor library.
0三字母作为实例
在生产中code刻意用。三字母继续构成
基于C的用户++负担。
0 instances of trigraphs being deliberately used in production code. Trigraphs continue to pose a burden on users of C++.
的议案笔记(粗体强调从原来的建议):
The proposal notes (bold emphasis from the original proposal):
如果三字母是从语言完全删除,一个
实现,希望支持他们能继续这样做:其
从物理源文件中的字符来实现自定义映射
基本源字符集可以包含三字符转换(与
甚至可以忌生吃字符串内这样做)。 我们不需要
在标准的三字母的向后兼容性
这篇关于是有向图和三字母当今使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!