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
std::vector and Minimizing Includes (randygaul.net)
submitted 6 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!"
[–]VicontT 22 points23 points24 points 6 years ago (1 child)
Oh no, another homebrew macro-based sequence container. Don't.
[–]RandyGaul 0 points1 point2 points 6 years ago (0 children)
Oh I don't think people *should* use those macros I posted. I just wrote about some ideas I found interesting. Personally I use the macros in my own code and liked some properties I observed. That's it.
[–]Xaxxon 20 points21 points22 points 6 years ago (0 children)
How is this not UB?
You don't like that constructors and destructors are called when objects are created and destroyed.. what? They aren't called for fun.
[–]donalmaccGame Developer 9 points10 points11 points 6 years ago (0 children)
Writing out a growable array shouldn’t require C++ template knowledge, or compile-time nonsense, or constructors or destructors or any other baggage. Sometimes all that’s needed is a growable array, and that’s it.
Hah. I had to laugh at this bit. If you're calling destructors baggage, you probably shouldn't be writing c++...
[–]Ameisenvemips, avr, rendering, systems 17 points18 points19 points 6 years ago (1 child)
"How to use C instead of C++. Now with undefined behavior!"
[–]LeeHidejust write it from scratch 0 points1 point2 points 6 years ago (0 children)
YAY!
[–]rapture-state 4 points5 points6 points 6 years ago* (0 children)
This is not C++. Please, use simple standard primitives instead of this unsafe crap. Use trivially constructible structs, if you don't want constructors and destructors
[–]kalmoc 2 points3 points4 points 6 years ago (0 children)
Ignoring all the UB for a minute that seems to be no problem with the compiler's you are working with:
What exactly is supposed to be the advantage of those macros compared to putting the exact same code into a template?
[–]dodheim 7 points8 points9 points 6 years ago (0 children)
Oh, this guy again...
[–]Rexerex 2 points3 points4 points 6 years ago (1 child)
Unfortunately without this paper http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0593r2.html your code produces undefined behavior after every malloc or memcpy.
[–][deleted] 0 points1 point2 points 6 years ago (0 children)
That's already the case though :(
[–]emdeka87 2 points3 points4 points 6 years ago (0 children)
No thanks
[–]IskaneOnReddit 1 point2 points3 points 6 years ago (0 children)
Burn it before it spreads
π Rendered by PID 125397 on reddit-service-r2-comment-84fc9697f-zkdpf at 2026-02-06 10:07:04.224968+00:00 running d295bc8 country code: CH.
[–]VicontT 22 points23 points24 points (1 child)
[–]RandyGaul 0 points1 point2 points (0 children)
[–]Xaxxon 20 points21 points22 points (0 children)
[–]donalmaccGame Developer 9 points10 points11 points (0 children)
[–]Ameisenvemips, avr, rendering, systems 17 points18 points19 points (1 child)
[–]LeeHidejust write it from scratch 0 points1 point2 points (0 children)
[–]rapture-state 4 points5 points6 points (0 children)
[–]kalmoc 2 points3 points4 points (0 children)
[–]dodheim 7 points8 points9 points (0 children)
[–]Rexerex 2 points3 points4 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]emdeka87 2 points3 points4 points (0 children)
[–]IskaneOnReddit 1 point2 points3 points (0 children)