Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct subproblem
- {
- ...
- virtual void solve (double& solution, double parameter)=0;
- }
- struct subproblem0: public subproblem
- {
- ...
- virtual void solve (double& solution, double parameter){...};
- }
- struct subproblem1: public subproblem
- {
- ...
- virtual void solve (double* solution, double parameter){...};
- }
- int main{
- subproblem problem[2];
- subproblem[0] = new subproblem0();
- subproblem[1] = new subproblem1();
- double argument0(0),
- argument1(1),
- sol0[2],
- sol1[2];
- for(unsigned int i(0);i<2;++i)
- {
- problem[i]->solve( &(sol0[i]) , argument0);
- problem[i]->solve( &(sol1[i]) , argument1);
- }
- return 0;
- }
- Arg<T1,T2> argument0(f1,f2)
- template<T1,T2> solve (double* solution, Arg<T1,T2> parameter)
- struct param_list_base {
- virtual double getParam(int i) const = 0;
- };
- template <typename ParamStorage>
- struct param_list : param_list_base {
- const ParamStorage& params;
- param_list(const ParamStorage& aParams) : params(aParams) { };
- virtual double getParam(int i) const {
- return params[i];
- };
- };
- class subproblem {
- protected:
- virtual void solve_impl(double* sol, param_list_base* params) = 0;
- public:
- template <typename ParamStorage>
- void solve(double* sol, ParamStorage params) {
- param_list<ParamStorage> tmp(params);
- solve_impl(sol, &tmp);
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement