C++: Factory With Self-Registering Types

Writing a factory method might be simple:
unique_ptr create(name) {
if (name == “Abc") return make_unique<AbcType>();
if (name == "Xyz") return make_unique<XyzType>();
if (…) return …

return nullptr;
}
Just one switch/if and then after a match you return a proper type.

Link: https://dzone.com/articles/factory-with-self-registering-types?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev