c++ templates dependent on input from file -


i have complicated c++ scientific code, uses multiple libraries. imagine there 5 different types of libraries, linear solver, integration tool, etc. each library type there several different libraries same thing, have different internal implementation. in fact, every library wrapper class implemented, such libraries of same type have same interface.

now, want give software user. want user able select libraries want use after code compiled. done means of input file.

the problem coding in main program. when coding library selection, end using nested ifs, explicitly coding every possible combination of libraries, conditioned on parameters read file. wondering if there tidy way this.

you can't implement templates dependent in input files, since template types resolved in compilation, not runtime.

the tidy way polymorphism (also, elegant way ;d).

define base class defines interface each implementation, create children classes each 1 it's own implementation, , then, (using input file...or not... call) resolve algorithm use polymorphism.

:) luck.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -