Assigning exprtk variables as vector members

2019-03-03 17:32发布

问题:

I asked very specific question here but I realized where the problem is and it's slightly more general. Seeing ALL exprtk examples and code pieces, everyone uses exprtk's basic metod add_variable as

double variab;
exprtk::symbol_table<double> my_symbol_table;
my_symbol_table.add_variable("name_of_variable", variab);

and never as

std::vector<double> variab{0.};
exprtk::symbol_table<double> my_symbol_table;
my_symbol_table.add_variable("name_of_variable", variab[0]);

Is there a reason? I cannot find anything on exprtk's readme.txt, it is just never mentioned, they switch immediately on adding a vector in the string expression corresponding to a c++ vector, which is not the case I want.

In my case I have several variables on the string with a random name and I want to match them on double variables inside a container . The example in the question linked seems to suggest that this doesn't work.

Any ideas?