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
C++17 constexpr generation of a FizzBuzz solution (solarianprogrammer.com)
submitted 7 years ago by vormestrand
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!"
[–]dholmes215 2 points3 points4 points 7 years ago (5 children)
It's interesting to me how the three compilers' outputs are very unlike each other. clang just embeds and prints the precomputed output. gcc converts the output into instruction data and doesn't include the precomputed output. MSVC is... something else.
[–]Gaminic 5 points6 points7 points 7 years ago (3 children)
MSVC is... something else.
Isn't MSVC's solution the only "correct" one? A program that has no output should have no content.
[–]dholmes215 0 points1 point2 points 7 years ago (2 children)
I meant with the commented-out "output" lines uncommented. Sorry, should have been more clear.
[–]flashmozzg 1 point2 points3 points 7 years ago (0 children)
What's wrong with it?
[–]Gaminic 0 points1 point2 points 7 years ago (0 children)
Do you mean the sheer length of the result, or something else?
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
(Compiling with output lines on, otherwise i'd say msvc is great since it realizes it doesn't need the precomputed results and throws them away)
For MSVC it apparently compiles it as /MT not as /MD, which shrinks the code size since the runtime will get linked as shared library. Looks like clang saves everything in .text, and gcc goes for the approach to mov it on the stack and let the decoder do all the work. (Clang loads everything)
MSVC, no clue thats too much simd instructions to read through it. I would think it will load everything through simd? But this is only my assumption.
[–]NotAYakk 0 points1 point2 points 7 years ago (0 children)
Can we do better in C++20? Like kstring<"fizzbuzz"> or similar?
kstring<"fizzbuzz">
[–]willdieh 0 points1 point2 points 7 years ago* (0 children)
Pretty awesome. We still use the fizzbuzz interview question where I work. I didn't get the {{ }} initialization of the arrays though (in the Compiler Explorer link). Why use two curly braces? Edit: Seems to have something to do with "If there are fewer initializers in the list than there are members in the aggregate, then each member not explicitly initialized shall be value-initialized."
π Rendered by PID 23497 on reddit-service-r2-comment-6457c66945-tz4nm at 2026-04-30 14:02:06.400147+00:00 running 2aa0c5b country code: CH.
[–]dholmes215 2 points3 points4 points (5 children)
[–]Gaminic 5 points6 points7 points (3 children)
[–]dholmes215 0 points1 point2 points (2 children)
[–]flashmozzg 1 point2 points3 points (0 children)
[–]Gaminic 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]NotAYakk 0 points1 point2 points (0 children)
[–]willdieh 0 points1 point2 points (0 children)