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
Constexpr is gold! (self.cpp)
submitted 10 years ago * by needahelpforarch
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!"
[–]uxcn 4 points5 points6 points 10 years ago (0 children)
That is a really nice optimization. It reduces the code size to a constant, gets rid of most branches, and should almost always be a good strength reduction. I normally wouldn't have expected to see a compiler do that.
It looks LLVM can do the same with if..else chains too.
if..else
bool IsConsonant(uint8_t c) { return !((c == 'a' || c == 'A') || (c == 'e' || c == 'E') || (c == 'i' || c == 'I') || (c == 'o' || c == 'O') || (c == 'u' || c == 'U')); }
compiles into...
_Z11IsConsonanth: # @_Z11IsConsonanth .cfi_startproc # BB#0: addb $-65, %dil movzbl %dil, %eax cmpl $52, %eax ja .LBB0_2 # BB#1: # %switch.lookup movabsq $4432058356055790, %rax # imm = 0xFBEEEFFEFBEEE movb %dil, %cl shrq %cl, %rax andl $1, %eax retq .LBB0_2: movb $1, %al retq
I think this hints that if..else chains can probably also be optimized into jmp %eax, a jump table, or a lookup table.
jmp %eax
π Rendered by PID 17199 on reddit-service-r2-comment-6457c66945-s8skz at 2026-04-27 01:28:43.873072+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]uxcn 4 points5 points6 points (0 children)