I have several types created using policies, i.e.
template <typename PolicyA, typename PolicyB>
class BaseType : PolicyA, PolicyB
{};
struct MyPolicyA {};
struct MyPolicyB {};
struct OtherPolicyB {};
using SpecializedTypeX = BaseType<MyPolicyA, MyPolicyB>;
using SpecializedTypeY = BaseType<MyPolicyA, OtherPolicyB>;
Now I would like to introduce some mechanism which allows me to elegantly select which SpecializedType should be used basing on input from e.g. command line. Ideally, it would be a factory method creating object of the proper type, like:
auto CreateSelectedSpecializedType(const std::string &key);
// selected has type SpecializedTypeX
auto selected = CreateSelectedSpecializedType("SpecializedTypeX");
I'd appreciate any advice. Thanks!