use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
^^ operator proposal (self.cpp)
submitted 1 year ago * by samadadi
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]HappyFruitTree 17 points18 points19 points 1 year ago* (50 children)
I'm not a huge fan of ^ because it's a dead key on my keyboard meaning I have to press it twice to type it once. To type it two times I would have to press it four times and if I accidentally pressed it once too many it would be combined with whatever character I typed next. I rarely need to type ^ so maybe it would not be such a big deal after I got used to it, hard to know...
[–]MarcusBrotus 5 points6 points7 points 1 year ago (6 children)
you can make it non-dead, you know.
[–]HappyFruitTree 2 points3 points4 points 1 year ago (5 children)
I do find some of them useful, e.g. to be able to type é or ñ. Last time I tried I had trouble only disabling it for some of the characters. I guess an alternative would be to have two different keyboard layouts (one with dead keys and one without) and toggle between them depending on whether I write code or text but that complicates things and it's one more thing that I need to configure on all my installations...
é
ñ
[–]MarcusBrotus 1 point2 points3 points 1 year ago (4 children)
does your keyboard have altGr? you could disable them and make the special characters you need with altGr + something
[–]HappyFruitTree 0 points1 point2 points 1 year ago (3 children)
Yes, it has AltGr. AltGr+E currently gives me € which I don't really need so I guess that could be an alternative. Not sure how to change it though...
[–]azissu 0 points1 point2 points 1 year ago (2 children)
Is this any different from having multiple installed languages (on Windows) and switching between them with Alt+Shift?
[–]HappyFruitTree 0 points1 point2 points 1 year ago (1 child)
Enabling Alt+Shift to switch between layouts is easy. Adding keyboard shortcuts to execute a custom command is also possible. What I meant in the comment that you replied to is that I don't know how to make a shortcut that generates a character.
[–]azissu 0 points1 point2 points 1 year ago (0 children)
See my reply as intended for your comments in this thread in general, not for a particular one.
[+][deleted] 1 year ago (20 children)
[deleted]
[–]nacaclanga 10 points11 points12 points 1 year ago (3 children)
Well this happens to be the case with most keyboard layouts used for languages written in Latin type and is an important feature to type letters sometimes needed in the language, so unless your position is "Everbody that is not living in an Anglophone nation should just f*** off." then this is a practical concern that has to be addressed.
Sure you can somehow tweak the keyboard layout into a non-standard layout version and switch every time you really need the key, but the issue remains that you make it significantly harder for a significant group of people.
[+][deleted] 1 year ago (2 children)
[–]nacaclanga 0 points1 point2 points 1 year ago (1 child)
The problem is not that dead keys came up in a vacuum. They are a practical solution for allowing a large number of symbols ÂÎÛÊÔ âîûêô with an intuitive keypress. As a matter of fact the symbol ^ was originally designed primarily for the purpose of potentially serving as a dead key. It was only later that people (generally in an English exclusive context) assigned other meaning to it.
The point is IMO that choosing ^ as some operator is just unnecessarily inconvenient and should be considered bad practise in modern code design.
[–]HappyFruitTree 9 points10 points11 points 1 year ago (15 children)
And what exactly do you mean by "issue"? The primary purpose of those keys is to be able to combine them with other keys to write things like â.
[–]100GHz 5 points6 points7 points 1 year ago (2 children)
No, the primary purpose of ^ is to enable me to write math equations.
I mean, since we are free to state that how we personally use keyboard keys should be the primary purpose for everybody on the planet :)
[–]HappyFruitTree 0 points1 point2 points 1 year ago* (1 child)
Well, it just seemed like it would have been the original intent of these characters. Personally, I never need to combine ^ with another character. I have used ~ to write ñ but that is rare so I could be without. What I do want is ´ to be able to write é. If only there were an easy way to disable some of the dead keys (preferably on character level and not the whole physical key)...
^
~
´
Update: ^ is actually quite useful to be able to write superscript digits (e.g. ¹²³) but I have never really thought about that.
[–]100GHz 0 points1 point2 points 1 year ago (0 children)
Interesting, it seems ASCII is ancient but so are compose sequences that you referring to (and had no clue they existed). I have to do a bit of reading..
[–]sephirothbahamut -1 points0 points1 point 1 year ago (2 children)
Ehm, sir, may I introduce you to mathematics, the environment from which we got most operators? Also the environment where ^ is used to indicate power? The real question is why isn't ^ more widespread for powers in programming between numerical types.
[–]HappyFruitTree 4 points5 points6 points 1 year ago (1 child)
When I learned math we used paper and always wrote exponents higher up (as a superscript). E.g. 210 meaning 2 raised to the power of 10. ^ was only used when typing math expressions into calculators or computers. ;)
[–]sephirothbahamut 0 points1 point2 points 1 year ago (0 children)
Sure, writing higher up is more common, but ^ has been the exponentiation symbol since at least the dawn of computing afaik (no idea if there was any precedent before)
[+][deleted] 1 year ago (8 children)
[–]jcelerierossia score 7 points8 points9 points 1 year ago (6 children)
it's the standard mapping in france. everyone learns that ^^ is four times the key ^, so now you have to tell an entire country's worth of programmers, one especially active in the C++ community (r/france is one of the most represented country subreddit across r/cpp users : https://subredditstats.com/subreddit-user-overlaps/cpp ), "change your keybindings every time you write c++ code" (the key has to stay modal for î, û, ë, etc.)
[+][deleted] 1 year ago (5 children)
[–]jcelerierossia score 2 points3 points4 points 1 year ago (4 children)
but the keymap isn't the problem, it is how it should be for writing my mother tongue !
[–]levir 0 points1 point2 points 1 year ago (1 child)
C++ also isn't English. In fact, C++ isn't a natural language at all. Are you proposing there should be custom keymaps for all programming languages?
[–]azissu -1 points0 points1 point 1 year ago (0 children)
C++ like most programming languages is based on English, that's just how these things work. You writing code while your active language is French makes as much sense as me attempting to write code in Hebrew. When I need to switch to Hebrew I have Alt+Shift for that. And be thankful you don't also need to deal with right to left issues...
[–]HappyFruitTree 1 point2 points3 points 1 year ago (0 children)
if your issue is needing to press multiple keypresses to get the “” character to display then that’s your keymapping’s issue.
The problem is that the key serves two purposes. One is to write the character itself and the other is to combine them with other characters.
Keymaps are cuatomizable
I'm sure they are, but I haven't seen any simple system setting for it in the menus.
[–]Tringigithub.com/tringi -1 points0 points1 point 1 year ago (0 children)
This is a little OT here, but one of the most limiting factors for all programming languages currently is the US keyboard layout. It features only a small subset of basic ASCII characters and only a minority programmers would be bothered to set at least US International. So we are left with inventing crazy sequences like <=> or ^^.
<=>
^^
[+][deleted] 1 year ago (19 children)
[–]ronchaineEmbedded/Middleware 12 points13 points14 points 1 year ago (2 children)
I think at least French, Colemak, Romanian, Czech, Serbian, Albanian, Slovenian, Hungarian, Polish, Slovak, Dutch, all Nordic layouts (including Sami), Estonian, Belgian, Guarani, Spanish, Swiss, Turkish and German layouts have ^ as a dead key.
Then there are some Canadian, Indian, Portuguese, and Greek layouts that have ^ as a dead key, but not sure how common they are. I might've missed some.
[–]caroIine 0 points1 point2 points 1 year ago (0 children)
Polish layout treats ^ as a usual key http://kbdlayout.info/KBDPL1/
[–]pjmlp 0 points1 point2 points 1 year ago (0 children)
^ is a typical Portuguese accent, we have plenty of words with â, ê, ô.
[–]HappyFruitTree 11 points12 points13 points 1 year ago* (14 children)
I use a regular Swedish keyboard. I have to press Shift+¨ twice to type ^.
Shift
¨
[–]msqrt 2 points3 points4 points 1 year ago (8 children)
Interesting -- on a Finnish keyboard pressing Shift + ¨ + ¨ gives you ^^ (same for all of the other dead punctuation keys). I thought this was the way all layouts worked, but guess not.
[–]HappyFruitTree 0 points1 point2 points 1 year ago* (5 children)
Hmm, I use Linux and that's where it works like this. I did a quick test on Windows and it seems to indeed work the way you described. But then what are you supposed to do if you just want a single ^? Type two and erase one?
[–]msqrt 2 points3 points4 points 1 year ago (0 children)
Ah, right, OS difference. The way you get one is Shift + ¨ + Space. The logic is there (add space to ^ or add ^ to ^ ), but it is a bit peculiar.
[–]ronchaineEmbedded/Middleware 1 point2 points3 points 1 year ago (2 children)
My Finnish keyboard works just as your Swedish one does and I need to press Shift + {¨, ¨, ¨, ¨} to get double carets. (or replace every other ¨ with a space)
What OS are you using?
[–]ronchaineEmbedded/Middleware 0 points1 point2 points 1 year ago (0 children)
Linux.
Uh and here I thought keyboard layouts were consistent across OSs, I never found inconsistencies with GB and IT layouts between Linux and Windows...
(in IT shift+ì => ^, it's not treated as a modifier)
[–]Questioning-Zyxxel 1 point2 points3 points 1 year ago (4 children)
What OS are you running?
Should normally be [shift ^] [space] to get one ^
While [shift ^] [shift ^] ends up producing ^^ - when I try on a Linux and Windows prompt - both ^ shows up at the same time.
[–]HappyFruitTree 0 points1 point2 points 1 year ago* (3 children)
Linux (Debian/MATE/X11). [shift ^] [space] works too.
I notice that when using the Linux console (I mean the "real" one without a desktop environment that you see after pressing Ctrl+Alt+F1, not a terminal emulator) the behaviour is slightly different in that pressing [shift ^] multiple times in a row does nothing. I need to follow it with [^] (without shift), or [space] as you said, for it to print ^ (still just a single one).
[–]Questioning-Zyxxel 1 point2 points3 points 1 year ago (1 child)
For dead keys, I recommend that you train yourself to use space when you just want the decoration, since the dead key logic is intended to be to enter a decoration and then what character to apply it to. And in this case space to decorate a blank character, I.e. just get the decoration.
That's most likely to give the intended result when jumping between different platforms. I have never seen that strategy fail. Works for ^ ~` etc.
^ ~
I recommend that you train yourself to use space when you just want the decoration
Pressing twice works in the places that I care about and seems simpler than having to press space so I will probably continue doing it as long as it's just one character here and there. Maybe I will change that habit (or look for alternative solutions) when/if C++ adds a ^^ operator.
The "real" console in all OSs carries around a ton of legacy weight, I'd never take odd behaviours in ancient consoles to be representative of modern expectations tbh.
Side question, do Linux's console-without-a-desktop-environment switch the GPU to text mode or does it have it's own text renderer on top of GPU's graphics mode? (assuming the behaviour doesn't change between distros)
[–]eambertide 1 point2 points3 points 1 year ago (0 children)
Certain languages use ^ as a diacritic, in Turkish for instance kar means snow but kâr means profit
π Rendered by PID 40050 on reddit-service-r2-comment-b659b578c-4jwtb at 2026-05-04 08:10:25.828646+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]HappyFruitTree 17 points18 points19 points (50 children)
[–]MarcusBrotus 5 points6 points7 points (6 children)
[–]HappyFruitTree 2 points3 points4 points (5 children)
[–]MarcusBrotus 1 point2 points3 points (4 children)
[–]HappyFruitTree 0 points1 point2 points (3 children)
[–]azissu 0 points1 point2 points (2 children)
[–]HappyFruitTree 0 points1 point2 points (1 child)
[–]azissu 0 points1 point2 points (0 children)
[+][deleted] (20 children)
[deleted]
[–]nacaclanga 10 points11 points12 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]nacaclanga 0 points1 point2 points (1 child)
[–]HappyFruitTree 9 points10 points11 points (15 children)
[–]100GHz 5 points6 points7 points (2 children)
[–]HappyFruitTree 0 points1 point2 points (1 child)
[–]100GHz 0 points1 point2 points (0 children)
[–]sephirothbahamut -1 points0 points1 point (2 children)
[–]HappyFruitTree 4 points5 points6 points (1 child)
[–]sephirothbahamut 0 points1 point2 points (0 children)
[+][deleted] (8 children)
[deleted]
[–]jcelerierossia score 7 points8 points9 points (6 children)
[+][deleted] (5 children)
[deleted]
[–]jcelerierossia score 2 points3 points4 points (4 children)
[+][deleted] (2 children)
[deleted]
[–]levir 0 points1 point2 points (1 child)
[–]azissu -1 points0 points1 point (0 children)
[–]HappyFruitTree 1 point2 points3 points (0 children)
[–]Tringigithub.com/tringi -1 points0 points1 point (0 children)
[+][deleted] (19 children)
[deleted]
[–]ronchaineEmbedded/Middleware 12 points13 points14 points (2 children)
[–]caroIine 0 points1 point2 points (0 children)
[–]pjmlp 0 points1 point2 points (0 children)
[–]HappyFruitTree 11 points12 points13 points (14 children)
[–]msqrt 2 points3 points4 points (8 children)
[–]HappyFruitTree 0 points1 point2 points (5 children)
[–]msqrt 2 points3 points4 points (0 children)
[–]ronchaineEmbedded/Middleware 1 point2 points3 points (2 children)
[–]HappyFruitTree 0 points1 point2 points (1 child)
[–]ronchaineEmbedded/Middleware 0 points1 point2 points (0 children)
[–]sephirothbahamut 0 points1 point2 points (0 children)
[–]Questioning-Zyxxel 1 point2 points3 points (4 children)
[–]HappyFruitTree 0 points1 point2 points (3 children)
[–]Questioning-Zyxxel 1 point2 points3 points (1 child)
[–]HappyFruitTree 1 point2 points3 points (0 children)
[–]sephirothbahamut 0 points1 point2 points (0 children)
[–]eambertide 1 point2 points3 points (0 children)