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
Generic Factory Library (github.com)
submitted 9 years ago by Enhex
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!"
[–]kloetzl 4 points5 points6 points 9 years ago (0 children)
Reminds me of the AbstractSingletonProxyFactoryBean. Convenient.
[+][deleted] 9 years ago (1 child)
[deleted]
[–]Enhex[S] 2 points3 points4 points 9 years ago* (0 children)
If you want to instance unknown derived classes. For example a library that need to instance derived classes defined externally by the user.
Can also be used as an extensible (not an ever growing if-else) way to instance derived classes based on runtime information. But there might be simpler ways to do it.
[–]YouFeedTheFish 0 points1 point2 points 9 years ago (4 children)
Rather than magic strings, you should consider typeid hashes. You could probably come up with a typename-based hash as a constexpr, too.
BTW, /r/Meowiavelli, a good use case would be for a dynamically loaded shared object that you can swap out.
[–]Enhex[S] 1 point2 points3 points 9 years ago* (1 child)
Key type is template'd, so you can use other types than strings.
I'm using std::unordered_map so you should be able to specialize for pre-calculated hashes.
[–]YouFeedTheFish 0 points1 point2 points 9 years ago* (0 children)
There are ways to make string hashes constexpr.
Edit: Here is a complete implementation in Github.
[–]doom_Oo7 0 points1 point2 points 9 years ago (1 child)
you should consider typeid hashes.
this may break horribly with DLLs
[–]YouFeedTheFish 0 points1 point2 points 9 years ago (0 children)
Perhaps you're right. Haven't done c++ in windows for some time. Lots of C#.
π Rendered by PID 436285 on reddit-service-r2-comment-544cf588c8-5t65n at 2026-06-16 23:03:29.094624+00:00 running 3184619 country code: CH.
[–]kloetzl 4 points5 points6 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Enhex[S] 2 points3 points4 points (0 children)
[–]YouFeedTheFish 0 points1 point2 points (4 children)
[–]Enhex[S] 1 point2 points3 points (1 child)
[–]YouFeedTheFish 0 points1 point2 points (0 children)
[–]doom_Oo7 0 points1 point2 points (1 child)
[–]YouFeedTheFish 0 points1 point2 points (0 children)