Unforgettable factory revisited
holyblackcat.github.io·22h·
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...