Is there any design error by which I need the template type of the solution in every other class?
That dependency is quite common in Genetic Algorithm / Genetic Programming frameworks and it isn't per se a design error.
There are two reasons because of which your code looks that way:
classes that interact with
Solution
s often need to store them (trials, best so far...) or classes depending on them.Type erasure (e.g.
boost::any
) doesn't mix well andboost::variant
introduces unwanted constraints.member function templates cannot be declared virtualmember function templates cannot be declared virtual but virtual methods are often a necessity (in your snippet
applyOp
,exploreNg
...). In contrast ordinary members of class templates can be virtual and this is a further "incentive".
Consider that template template parameterstemplate template parameters (and good default values) could be a way to lower the perceived complexity of using the library and help with the coordination of the types among the various classes.