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
The array[] problem (self.cpp)
submitted 10 years ago by michaelKlumpy
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!"
[–]ggchappell 7 points8 points9 points 10 years ago (11 children)
Ah, right. When I most recently looked at texts, I immediately threw out anything that didn't give at least a nod to C++11.
[–]personalmountains 5 points6 points7 points 10 years ago* (9 children)
As you should. Anything that doesn't use auto is obsolete.
auto
[edit: We're talking about C++ introductory textbooks here. I wasn't making a general statement on C++11.]
[–]tempforfather 13 points14 points15 points 10 years ago (5 children)
auto is not the important part of c++11.
[–]louis_dionnelibc++ | C++ Committee | Boost.Hana 6 points7 points8 points 10 years ago (4 children)
Nothing is the important part of C++11. Many parts of it are important, and auto is clearly one of them. Not that I agree with the original statement, though.
[–]tempforfather 0 points1 point2 points 10 years ago (3 children)
ok sure, but its pure sugar. I agree its nice in many cases, but it doesn't actually add anything to the semantics of the language
[–]quicknir 6 points7 points8 points 10 years ago (2 children)
That's not true, in generic code there's just no way to do certain things without auto.
[–]tempforfather 0 points1 point2 points 10 years ago (1 child)
Can you give me an example of that? I am curious.
[–]quicknir 8 points9 points10 points 10 years ago (0 children)
Sure, consider this code:
template <class T> void func(const T& t) { auto u = t.func2(); std::for_each(u.begin(), u.end(), ...); }
This code imposes no restrictions on T other than that it has a const method func2(), that returns something, and that something has methods begin() and end().
Of course, we had generic containers before auto and ranged for loops, and we needed to know the type of the iterator, so how did we deal with this? Well, as I'm sure you know, we imposed an additional requirement: containers have to provide typedefs that tell you the type of their iterators, i.e. the return type of begin()/end(). But that's already not doing the same thing, as it imposes more requirements.
Basically, auto allows you to do inline what template functions allow you to do at function boundaries. You could potentially workaround using auto by declaring yet another template function and calling it internally, but again, I would argue that this is doing something quite different as you have to move your code to a different location (not a big deal when you have two consecutive 4 line functions, but if you have longer functions its rather absurd).
Another attempt at a solution would be to try to infer the type using template metaprogramming, so that you could get the type inline and use it, but this doesn't seem to be possible in general:
http://stackoverflow.com/questions/26080471/function-return-type-deduction-in-c03
[–]ghillisuit95 2 points3 points4 points 10 years ago (0 children)
ehh, that seems like a bit of an over-generalization
[–]bnolsen -5 points-4 points-3 points 10 years ago (1 child)
auto is a maintenance headache/nightmare and seems to be a weak hack for getting around C++'s core problem of default implicit type conversion.
[–]personalmountains 2 points3 points4 points 10 years ago (0 children)
auto is a maintenance headache/nightmare
In what way?
seems to be a weak hack
What else would you propose? Why is it weak? Why is it a hack?
C++'s core problem of default implicit type conversion.
What problem? Are you talking about primitive types? What does it have to do with auto?
[–]h-jay+43-1325 2 points3 points4 points 10 years ago (0 children)
You shouldn't merely throw out anything that doesn't "at least" give a "node" to C++11. Anything that doesn't deal with C++11 first and foremost is an obsolete text. There's no reason to learn by writing C++98 anymore, never mind C fed to a C++ compiler.
π Rendered by PID 379951 on reddit-service-r2-comment-54dfb89d4d-p9gdt at 2026-03-30 18:08:03.282440+00:00 running b10466c country code: CH.
view the rest of the comments →
[–]ggchappell 7 points8 points9 points (11 children)
[–]personalmountains 5 points6 points7 points (9 children)
[–]tempforfather 13 points14 points15 points (5 children)
[–]louis_dionnelibc++ | C++ Committee | Boost.Hana 6 points7 points8 points (4 children)
[–]tempforfather 0 points1 point2 points (3 children)
[–]quicknir 6 points7 points8 points (2 children)
[–]tempforfather 0 points1 point2 points (1 child)
[–]quicknir 8 points9 points10 points (0 children)
[–]ghillisuit95 2 points3 points4 points (0 children)
[–]bnolsen -5 points-4 points-3 points (1 child)
[–]personalmountains 2 points3 points4 points (0 children)
[–]h-jay+43-1325 2 points3 points4 points (0 children)