Unforgettable factory revisited
holyblackcat.github.io·17w·
Discuss: r/cpp

TL;DR:

This post presents some improvements to the original Unforgettable Factory Registration by Nir Friedman.

Reading that post is not a requirement (I explain everything from scratch), but if you’re already familiar with it, you can skip to the improvements part. (In short, I’m explaining how to remove the dependency on the default constructor instantiation.)

The problem statement

It’s often useful to know every class derived from a specific base, either to construct all of them, or to construct a specific derived class (typically by its name).

For example:

struct Animal
{
virtual ~Animal() = default;
virtual void Say() = 0;
};

...

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help