C++ Alternative Operator Representations
en.cppreference.com
en.cppreference.com
We auto-generated a humongous pull request for the Chromium source code and sent it out for review by all the various source code "owners" (super reviewers) who would need to sign off.
The change used the alternate encoding for curly and square brackets, claiming the original characters were inaccessible on an Icelandic keyboard layout (which is half true, and there were quite a few of us Icelanders around) and that therefore, to be inclusive, we would like to standardize on the alternative representation.
Good fun, although I don't remember if a single one of the reviewers was fooled :)
And I find its harder to typo and misread it:
`a && b || c` vs `a & b | c`
`a and b or c` vs `a & b | c`
English language keywords aren't always great for readability in my opinion. Ada's and then / or else syntax, for instance. They're the short-circuit syntax, whereas and and or give eager evaluation. [0] You can't determine that just from the syntax though, so it ends up being no less cryptic than using strange symbols the way C++ (typically) does.
[0] https://en.wikibooks.org/wiki/Ada_Programming/Operators#Shor...
"If new true friend not protected for explicit private union, break case and try using this."
I often write
if (not ...
for emphasis. The "bitand" etc. are similarly useful where the operator might otherwise be mistaken for "&&" or, particularly, "||".The only one that is an unfortunate choice is "compl", which just looks strange. When I feel a need to call attention to use of "~", I define a lambda "bitwise_not(bool)". But rarely.
https://en.cppreference.com/w/cpp/utility/functional/bit_not
if not nowhow not noway
... int operator"" _km(unsigned long long);
auto distance = 42_km;
The breadth of crazy features in C++ is really huge, when you dig in. template _km(ulong v) { enum _km = inKilometers(v); }
auto distance = _km!42;
It's used by the Sargon library to create a halffloat type:https://digitalmars.com/sargon/halffloat.html
I haven't seen it used in C++, though my C++ experience post this feature is limited.
"A safer string"s
Declares a std::string constant.While I agree C++ is huge, I doubt anyone would survive a Python, Java, C#, VB.NET, JavaScript, Typescript, Fortran, Ada, Common Lisp, COBOL, C pub quiz, based on the very latest language versions.
Its explained in the first two sentences of the page.
I am just surprised I’ve never seen this in any code base before.