C ++代码中的“ ???-”是什么意思? [英] What is the meaning of `???-` in C++ code?

查看:243
本文介绍了C ++代码中的“ ???-”是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一些旧代码中看到了以下代码:

  size_t a = 1 ???-2:0; 

符号 ???-是什么在C ++中意味着什么?我应该怎么理解?

解决方案

实际上是:

  size_t a = 1吗? 〜2:0; 

??-



因此添加了三字符组,以便程序员在不存在这些字符(通过编码或通过键盘)时访问它们的功能。



现在,它们已经过时,并且比绕过旧标准更有效地使读者迷惑。



真的很老,或者作者是个混蛋。


I saw the following code from some legacy codes:

 size_t a = 1 ???- 2 :0;

What does the symbol ???- mean in C++? How should I understand it?

解决方案

It's actually:

size_t a = 1 ? ~2 :0;

??- is a trigraph for ~


Trigraphs are from an old era... before some of us were even born.

Back in the days, there were some characters that weren't always supported. An unknowing programmer would try to type in such a character only to find that it doesn't exist on the keyboard!


Image Source: http://www.myoldmac.net/cgi-data/forum/phpBB2/viewtopic.php?t=305

So trigraphs were added to allow the programmer to access the functionality of these characters when they didn't exist (either in the encoding or from the keyboard).

Nowadays, they are obsolete and are more effective in confusing the reader than in getting around old standards.

So either that code is really old, or the author was being a jerk.

这篇关于C ++代码中的“ ???-”是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆