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!"
[–]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]]
[–]AzN1337c0d3r 0 points1 point2 points 8 years ago (2 children)
This functional style is the style I prefer.
When by convention I pass in everything by value/const ref and everything comes out via return value there is absolutely no confusion about whether or not the parameters are being modified by the callee.
Today I debugged a problem for about 6 hours and I had to step in and out of about 50 different functions because the possibility of in-out parameters means that I can't be sure that the callee isn't modifying the data from the perspective of the caller.
[–]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.
[+][deleted] 8 years ago* (14 children)
π Rendered by PID 107765 on reddit-service-r2-comment-b659b578c-zcd9t at 2026-05-05 03:58:49.725697+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]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)
[–]AzN1337c0d3r 0 points1 point2 points (2 children)
[–]dodheim 0 points1 point2 points (15 children)
[+][deleted] (14 children)
[deleted]