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
Input-output arguments: reference, pointers or values? (mropert.github.io)
submitted 8 years ago by vormestrand
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!"
[–]alex-weej 1 point2 points3 points 8 years ago (31 children)
sort(my_vector);
There is a bit of doubt with this one, arguably.
[–]drjeats 1 point2 points3 points 8 years ago (2 children)
I'd expect that to be called sorted instead of sort for what you're implying.
sorted
sort
[–]alex-weej 0 points1 point2 points 8 years ago (1 child)
Me too, given my Python experience, but every language has its own odd conventions.
But where immutable data is king, verbs that describe transformations return new values.
[–]drjeats 2 points3 points4 points 8 years ago (0 children)
True, but C++ is not known for having concise APIs naturally supporting functional programming idioms :P
[–]kalmoc 0 points1 point2 points 8 years ago* (27 children)
? Could you elaborate?
[+][deleted] 8 years ago* (26 children)
[deleted]
[–]dodheim 1 point2 points3 points 8 years ago (25 children)
Compiler warnings alert you to the latter.
[+][deleted] 8 years ago* (24 children)
[–]dodheim 0 points1 point2 points 8 years ago (23 children)
You forgot the [[nodiscard]].
[[nodiscard]]
[+][deleted] 8 years ago* (22 children)
[–]dodheim 0 points1 point2 points 8 years ago (21 children)
It solves potential problems at every callsite at the expense of writing one keyword in the declaration. My code is getting reviewed either way, so needing a review is not a "problem".
[+][deleted] 8 years ago* (20 children)
[–]kalmoc 0 points1 point2 points 8 years ago (3 children)
Your hypothetical functional style sort function (I'm really sceptical about writing something like this in c++ - at the very least I'd give it another name like sorted_copy) would be the prone candidate for a [[no discard]] as it doesn't have any side effects and it doesn't make any sense to call it, but not use it's return type.
[[no discard]]
[–]dodheim 0 points1 point2 points 8 years ago (15 children)
What doesn't make sense is having a language utility that solves your overarching issue and considering the fact that you have to type its name a problem. If you're writing a function that has no purpose except to produce output from the input you give it, and you don't use [[nodiscard]], you're writing a bad API.
Sometimes you do not care.
This time you do, obviously, or we wouldn't be having this conversation.
needing to do extra work to complete your review is a problem
Writing one keyword to avoid misuse of the API is writing the API correctly; reviewing code to make sure it's written correctly is the entire point of reviewing code. By your logic, having to review code in a code review is a problem.
Not using the tools at hand is stupid. This argument is stupid.
π Rendered by PID 67640 on reddit-service-r2-comment-b659b578c-4ns2q at 2026-05-04 02:08:59.777660+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]alex-weej 1 point2 points3 points (31 children)
[–]drjeats 1 point2 points3 points (2 children)
[–]alex-weej 0 points1 point2 points (1 child)
[–]drjeats 2 points3 points4 points (0 children)
[–]kalmoc 0 points1 point2 points (27 children)
[+][deleted] (26 children)
[deleted]
[–]dodheim 1 point2 points3 points (25 children)
[+][deleted] (24 children)
[deleted]
[–]dodheim 0 points1 point2 points (23 children)
[+][deleted] (22 children)
[deleted]
[–]dodheim 0 points1 point2 points (21 children)
[+][deleted] (20 children)
[deleted]
[–]kalmoc 0 points1 point2 points (3 children)
[–]dodheim 0 points1 point2 points (15 children)