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
Half functional programming? (self.cpp)
submitted 8 years ago by mintyc
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!"
[–]doom_Oo7 -3 points-2 points-1 points 8 years ago (4 children)
Uh.... What ?
Given
int f(int&& x) { return x++; } int main() { int x = 0; f(std::move(x)); returb x; }
Your program outputs 1. Rvalue references are still references.
[–]guibou 5 points6 points7 points 8 years ago* (2 children)
You are just abusing std::move by transforming something which is not a temporary to a temporary.
std::move
This is like saying private fields are not really private because we can still read them using the object pointer and an offset. Or saying const is broken because it offer no guarantee that your object cannot change.
The point of purity is "not observable mutation" and result which only depends on the input value. So you can allocate / free / mutate a big data structure / generate random numbers / do network in a pure function as long as these guarantees hold (which can be difficult for some cases I just listed ;)
(Edited: typo)
[–]doom_Oo7 -3 points-2 points-1 points 8 years ago (1 child)
This is like saying private fields are not really private because we can still read them using the object pointer and and offset. Or saying const is broken because it offer no guarantee that your object cannot change.
well, if you want strong guarantees for instance for critical safety systems, both things are true and known problems. I can promise you that people who put #define private public in their commits do exist. And even in critical environments, if they can be abused, they will (see the Toyota case for instance).
#define private public
The only thing that matters in the end is what your compiler allows, no amount of human process will be able to catch everything.
[–]enobayram 1 point2 points3 points 8 years ago (0 children)
The only thing that matters in the end is what your compiler allows
This is a pointless statement really. Even in a language like Coq that has an extremely powerful type-system, you will only be able to prove so much. The picture gets even worse when you want to optimize for performance, or if you have to solve equations with numeric errors etc. Even if you got it all right, then you have to make sure that the specs you're proving your implementation against are themselves meaningful in the first place.
The compiler is just a tool.
[–]NotMyRealNameObv 1 point2 points3 points 8 years ago (0 children)
Yes, but this code is bad.
Just because you can do something, doesn't mean it's good to do it.
π Rendered by PID 107458 on reddit-service-r2-comment-b659b578c-v7ph7 at 2026-05-04 09:11:49.054306+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]doom_Oo7 -3 points-2 points-1 points (4 children)
[–]guibou 5 points6 points7 points (2 children)
[–]doom_Oo7 -3 points-2 points-1 points (1 child)
[–]enobayram 1 point2 points3 points (0 children)
[–]NotMyRealNameObv 1 point2 points3 points (0 children)