digraphs

Are digraphs and trigraphs in use today? [closed]

╄→гoц情女王★ 提交于 2019-11-28 22:25:08
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? (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 [ ) 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

<: cannot begin a template argument list

淺唱寂寞╮ 提交于 2019-11-28 21:22:06
I get an error <: cannot begin a template argument list on g++ compiler. Code template<typename T> class SomeClass; class Class; SomeClass<::Class>* cls; According to the Maximal Munch tokenization principle a valid C++ token must collect/have as many consecutive characters as possible. <: is a digraph (an alternative representation of symbol [ ). Digraph Equivalent <: [ :> ] <% { %> } %: # So SomeClass<::Class>* cls; is interpreted as SomeClass[:Class>* cls; which doesn't make any sense. Solution: Add a whitespace between < and : SomeClass< ::Class>* cls; ^ | White Space Kirill V. Lyadvinsky

Are digraphs and trigraphs in use today? [closed]

微笑、不失礼 提交于 2019-11-27 20:55:14
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . 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? (Note: Here, "digraph" does not mean "directed graph."

Why are there digraphs in C and C++?

依然范特西╮ 提交于 2019-11-27 00:47:41
I learned today that there are digraphs in C99 and C++. The following is a valid program: %:include <stdio.h> %:ifndef BUFSIZE %:define BUFSIZE 512 %:endif void copy(char d<::>, const char s<::>, int len) <% while (len-- >= 0) <% d<:len:> = s<:len:>; %> %> My question is: why do they exist? Digraphs were created for programmers that didn't have a keyboard which supported the ISO 646 character set. http://en.wikipedia.org/wiki/C_trigraph I believe that their existence can be traced back to the possibility that somewhere, somebody is using a compiler with an operating system whose character set

What is this smiley-with-beard expression: “<:]{%>”?

不羁的心 提交于 2019-11-26 14:51:33
I came across the following program, which compiles without errors or even warnings: int main(){ <:]{%>; // smile! } Live example. What does the program do, and what is that smiley-expression? That's an empty lambda using a digraph disguise. Normal lambdas don't have beards. 0x499602D2 The program uses digraphs to represent the following: [] {}; This is a lambda expression that does nothing. The corresponding symbols have these equivalents: <: = [ %> = } Though they are generally unneeded today, digraphs are useful for when your keyboard lacks certain keys necessary to use C++'s basic source

Why are there digraphs in C and C++?

筅森魡賤 提交于 2019-11-26 12:25:01
问题 I learned today that there are digraphs in C99 and C++. The following is a valid program: %:include <stdio.h> %:ifndef BUFSIZE %:define BUFSIZE 512 %:endif void copy(char d<::>, const char s<::>, int len) <% while (len-- >= 0) <% d<:len:> = s<:len:>; %> %> My question is: why do they exist? 回答1: Digraphs were created for programmers that didn't have a keyboard which supported the ISO 646 character set. http://en.wikipedia.org/wiki/C_trigraph 回答2: I believe that their existence can be traced

When were the &#39;and&#39; and &#39;or&#39; alternative tokens introduced in C++?

感情迁移 提交于 2019-11-26 02:03:03
I've just read this nice piece from Reddit. They mention and and or being "Alternative Tokens" to && and || I was really unaware of these until now. Of course, everybody knows about the di-graphs and tri-graphs , but and and or ? Since when? Is this a recent addition to the standard? I've just checked it with Visual C++ 2008 and it doesn't seem to recognize these as anything other than a syntax error. What's going on? MSVC supports them as keywords only if you use the /Za option to disable extensions; this is true from at least VC7.1 (VS2003). You can get them supported as macros by including

When were the &#39;and&#39; and &#39;or&#39; alternative tokens introduced in C++?

家住魔仙堡 提交于 2019-11-26 01:08:32
问题 I\'ve just read this nice piece from Reddit. They mention and and or being \"Alternative Tokens\" to && and || I was really unaware of these until now. Of course, everybody knows about the di-graphs and tri-graphs, but and and or ? Since when? Is this a recent addition to the standard? I\'ve just checked it with Visual C++ 2008 and it doesn\'t seem to recognize these as anything other than a syntax error. What\'s going on? 回答1: MSVC supports them as keywords only if you use the /Za option to