I have a class that has a constructor taking quite a few parameters
enum class FooType {FOO_A, FOO_B, FOO_C};
class Foo {
Foo(const double a, const double b, .... const double n);
}
depending on the 'type', I only need a certain subset of the params. At the moment there are various constructors with different number of inputs, but some new types will be added so that the number of inputs is the same. I could just add the type to the constructor, have a long switch in it, but the params list is quite long.
Foo(FooType type, const double a, const double b, .... const double n) {
if (type = FooType::FOO_A) {
...
} else if ....
}
Doesn't seem too bad, but I also don't like having that long parameter list. Seems to easy to make typos that are a pain to debug. So I can a.) pass a structure in b.) do something else
and I am just curious about potential b solutions.
Is it possible to templateize this such that I could create a template constructor and call the constructor with something like
std::make_shared<Foo<FooType::FOO_A>>(a, b, c);
Note: I don't want to use inheritance since the rest of the class' functionality has absolutely no use/need for it.